home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1997 February / PC Shareware 1997-02.iso / programy / envlp122 / envelop.3 / Program / tools.eto < prev    next >
Text File  |  1996-03-15  |  85KB  |  2,793 lines

  1. Type ScreenLayout
  2.   Dim curItem As Integer
  3.   Dim ScreenWidth As Integer
  4.   Dim ScreenHeight As Integer
  5.  
  6.   ' METHODS for object: ScreenLayout
  7.   Sub Clear
  8.     ' Destroy all embedded layout items
  9.     Dim wli As WindowLayoutItem
  10.     For Each wli EmbeddedIn Me
  11.       DestroyObject(wli)
  12.     Next 
  13.   End Sub
  14.  
  15.   Sub DebugRestoreLayout()
  16.     Dim wli As WindowLayoutItem
  17.   
  18.     ' Restore the saved visibility of all the windows.
  19.     For Each wli EmbeddedIn Me
  20.       If (wli.wnd) Then wli.wnd.Visible = wli.visible
  21.     Next 
  22.   End Sub
  23.  
  24.   Sub DebugShowLayout()
  25.     Dim wli As WindowLayoutItem
  26.   
  27.     ' Make all the windows visible, so we can see if they fit in layout.
  28.     For Each wli EmbeddedIn Me
  29.       If (wli.wnd) Then wli.wnd.Visible = True
  30.     Next 
  31.   End Sub
  32.  
  33.   Sub EnsurePixels()
  34.     ' The heuristic we'll use to decide whether an item needs to be scaled
  35.     ' from twips to pixels is whether either of height or width is greater
  36.     ' than 2000. This gets us away from the dangerous boundary cases where
  37.     ' an item is saved in pixels, but is still near 1000 pixels in size, and
  38.     ' also stays away from dependencies on the current screen resolution.
  39.     ' It does introduce the possibility that a small form saved in twips
  40.     ' may grow to be huge because we failed to scale it here. Tough.
  41.     ' Furthermore, if I'm an EnvelopScreenLayout, then I was made at 15
  42.     ' twips per pixel, period. Otherwise go ahead and use the tpp figure
  43.     ' from the current display settings (found on Screen object).
  44.     Dim WLI as WindowLayoutItem
  45.     Dim factorX, factorY As Single
  46.     If TypeOf Me Is EnvelopScreenLayout Then
  47.       factorX = 15 : factorY = 15
  48.     Else
  49.       factorX = Screen.TwipsPerPixelX : factorY = Screen.TwipsPerPixelY
  50.     End If
  51.  
  52.     For Each WLI EmbeddedIn Me
  53.       If (WLI.height > 2000) || (WLI.width > 2000) Then
  54.         WLI.left_ = WLI.left_ / factorX
  55.         WLI.top = WLI.top / factorY
  56.         WLI.width = WLI.width / factorX
  57.         WLI.height = WLI.height / factorY
  58.       End If
  59.     Next WLI
  60.   End Sub
  61.  
  62.   Function FitsScreen As Boolean
  63.     FitsScreen = (ScreenWidth <= Screen.pixelWidth) && (ScreenHeight <= Screen.pixelHeight)
  64.   End Function
  65.  
  66.   Sub Mark
  67.     ' Mark all embedded items as not-visited
  68.     Dim wli As WindowLayoutItem
  69.     For Each wli EmbeddedIn Me
  70.       wli.wnd = Nothing
  71.     Next 
  72.   End Sub
  73.  
  74.   Sub Purge
  75.     ' Destroy all embedded items that don't have a window recorded.
  76.     Dim wli As WindowLayoutItem
  77.     For Each wli EmbeddedIn Me
  78.       If (wli.wnd = Nothing) Then DestroyObject(wli)
  79.     Next 
  80.   End Sub
  81.  
  82.   Sub RestoreLayout()
  83.     ' Restore windows' position/visibility as recorded by embedded items.
  84.     Dim suspend as new SuspendDebugExceptionTrapping
  85.     Dim wli As WindowLayoutItem
  86.   
  87.     EnsurePixels
  88.     For Each wli EmbeddedIn Me
  89.       If wli.wnd Then 
  90.         Try
  91.           ' For non-Form objects, we know they need to be created first.
  92.           If Not TypeOf wli.wnd Is Form Then wli.wnd.Visible = wli.visible
  93.           If TypeOf wli.wnd Is Window Then 
  94.             ' Children of Window use twip coordinates
  95.             With Screen
  96.               wli.wnd.Move(wli.left_ * .TwipsPerPixelX, wli.top * .TwipsPerPixelY, wli.width * .TwipsPerPixelX, wli.height * .TwipsPerPixelY)
  97.             End With
  98.           Else 
  99.             ' Objects that don't inherit from Window use pixel coordinates
  100.             wli.wnd.Move(wli.left_, wli.top, wli.width, wli.height)
  101.           End If
  102.           wli.wnd.Visible = wli.visible
  103.   
  104.           ' Notify the window itself, if it has a "ScreenLayoutRestore" method.
  105.           If (MethodExists(wli.wnd, "ScreenLayoutRestore")) Then wli.wnd.ScreenLayoutRestore()
  106.   
  107.         catch NotFound(s as string)
  108.         End Try
  109.       End If
  110.     Next 
  111.   End Sub
  112.  
  113.   Sub SaveExplicitWindow(nm As String)
  114.     dim o as Object
  115.     ' Given the string-name of an object, if it refers to an real object
  116.     ' and it isn't already recorded, then save it.
  117.     o = FindObject(nm)
  118.     If o Then 
  119.       dim wli As WindowLayoutItem
  120.       For Each wli EmbeddedIn Me
  121.         If wli.wnd = o Then Exit Sub
  122.       Next 
  123.     End If
  124.     SaveWindow(o)
  125.   End Sub
  126.  
  127.   Sub SaveExplicitWindows()
  128.     ' This method is meant to be overridden to get certain windows saved explicitly.
  129.   End Sub
  130.  
  131.   Sub SaveLayout()
  132.     ' For each window record size/location and visibility information
  133.     Dim suspend as new SuspendDebugExceptionTrapping
  134.     curItem = 1
  135.   
  136.     Mark ' Mark all items as not-visited
  137.   
  138.     ' Save all created windows (have a Windows HWND)
  139.     Screen.EnumWindows(Me, "SaveWindowFromHwnd")
  140.     ' Save some windows explicitly
  141.     SaveExplicitWindows()
  142.   
  143.     Purge ' Purge items which where not visited by the Save
  144.   
  145.     ' Record the screen width & height this layout was saved on
  146.     ScreenWidth = Screen.pixelWidth
  147.     ScreenHeight = Screen.pixelHeight
  148.   End Sub
  149.  
  150.   Sub SaveWindow(wnd As Object)
  151.     dim wndItem as WindowLayoutItem
  152.     dim wndItemName As String
  153.     dim factorX, factorY as Single
  154.  
  155.     ' If wnd is a child of Window, its coordinates will be in twips, it will
  156.     ' need to be converted since all saved coordinates are in pixels.
  157.     If TypeOf wnd is Window then
  158.       factorX = 1.0 / Screen.TwipsPerPixelX
  159.       factorY = 1.0 / Screen.TwipsPerPixelY
  160.     Else
  161.       factorX = 1
  162.       factorY = 1
  163.     End If
  164.  
  165.     wndItemName = "Item" & curItem
  166.   
  167.     ' Find or make a WindowLayoutItem object to hold the information
  168.     wndItem = FindEmbed(Me, wndItemName)
  169.     If Not wndItem Then wndItem = EmbedObject(Me, WindowLayoutItem, wndItemName)
  170.   
  171.     ' Fill in the information
  172.     Try
  173.       wndItem.wnd = wnd
  174.       wndItem.left_ = wnd.Left * factorX
  175.       wndItem.top = wnd.Top * factorY
  176.       wndItem.width = wnd.Width * factorX
  177.       wndItem.height = wnd.Height * factorY
  178.       wndItem.visible = wnd.Visible
  179.       curItem = curItem + 1
  180.     catch NotFound(s as string)
  181.       ' This window could not be saved successfully, disregard it.
  182.     End Try
  183.   End Sub
  184.  
  185.   Sub SaveWindowFromHwnd(ByVal hWnd As Long)
  186.     dim o as Object
  187.     o = FindObjectFromWindow(hWnd)
  188.     If o Then SaveWindow(o)
  189.   End Sub
  190.  
  191.   Function ShortName As String
  192.     Dim name As String
  193.     Dim pos, nextPos As Integer
  194.     pos = 1
  195.     name = Me
  196.     Do
  197.       nextPos = Instr(pos, name, ".")
  198.       If nextPos > 0 Then pos = nextPos + 1
  199.     Loop While nextPos > 0
  200.     name = Mid(name, pos)
  201.     ShortName = name
  202.   End Function
  203.  
  204. End Type
  205.  
  206. Type ToolGadget From ButtonGadget
  207.   Dim bitmap As New Bitmap
  208.   Dim HintText As String
  209.  
  210.   ' METHODS for object: ToolGadget
  211.   Sub DragAndDrop(o as XferData, x,y as single, state as OleDropState, effect as OleDropEffect)
  212.     ' Forward all Drag&Drop stuff to ObjectBox
  213.     If Parent Then SendEvent Parent.DragAndDrop(o, x, y, state, effect)
  214.   End Sub
  215.  
  216.   Sub DragStart(o as XferData, x,y as single)
  217.     o.ObjectRef = Me
  218.     o.Drag(1)
  219.   End Sub
  220.  
  221. End Type
  222.  
  223. Type InstallButton From Image
  224.   Dim installObject As Window
  225.   Dim BmpOpen As New OpenDialog
  226.   Dim installBitmap As New Bitmap
  227.   Dim SourceModule As String
  228.   Dim InstalledSomething As Boolean
  229.   Dim TargetPalette As ObjectBox
  230.   Dim DefaultBitmap As New Bitmap
  231.   Type InstallPair
  232.     Dim bitmap As Bitmap
  233.     Dim obj As Object
  234.   End Type
  235.   Property InstallName Get getInstallName As String
  236.   Event Install
  237.  
  238.   ' METHODS for object: InstallButton
  239.   Sub Click()
  240.     dim CheckOf as New SuspendDebugExceptionTrapping
  241.   
  242.     BevelOuter = "Inset"
  243.     InstalledSomething = False
  244.     EnumObjectEmbeds(Me, Me, "EnumMethod")
  245.     If Not InstalledSomething Then 
  246.       InfoBox.Message("Install not setup", "Installation configuration not correct.")
  247.     End If
  248.     BevelOuter = "Raised"
  249.   End Sub
  250.  
  251.   Function Config(g as Object) As Boolean
  252.     Dim ng as new ControlTools.Gadget
  253.   
  254.     ' If we were given an object, then take a guess about
  255.     ' intended Object, apply it to a local ControlTools.Gadget,
  256.     ' and call Detailed Edit to give a chance to Reconfigure
  257.     If g Then 
  258.       If IsPrototype(g) Then 
  259.         ng.GadgetObject = g
  260.       Else 
  261.         Dim od as new ObjDebug
  262.         od.Obj = g
  263.         ng.GadgetObject = od.ParentObject
  264.       End If
  265.     Else 
  266.       ng.GadgetObject = installObject
  267.     End If
  268.   
  269.     ' Set the bitmap default
  270.     ng.bitmap.SetPicture installBitmap.GetPicture
  271.   
  272.     ' Edit the gadget. Cancel will leave the GadgetObject empty.
  273.     ' If not cancel, configure the install object and bitmap
  274.     ng.DetailedEdit
  275.     If ng.GadgetObject = "" Then 
  276.       Config = False
  277.       Exit Function
  278.     Else 
  279.       installObject = FindObject(ng.GadgetObject)
  280.       installBitmap.SetPicture ng.bitmap.GetPicture
  281.   
  282.       Picture = installBitmap
  283.       Refresh
  284.       Config = True
  285.     End If
  286.   End Function
  287.  
  288.   Function DetailedEdit() As Long
  289.     DetailedEdit = Config(Nothing)
  290.   End Function
  291.  
  292.   Sub DragAndDrop(source As XferData, x As Single, y As Single, state As OleDropState, effect As OleDropEffect)
  293.     dim g as object
  294.     g = source.ObjectRef
  295.   
  296.     ' Default to "don't accept"
  297.     effect = 0
  298.   
  299.     ' If DROP ...
  300.     If state = "Drop" Then 
  301.       If Config(g) Then effect = 1
  302.     Else  ' DRAG OVER
  303.       ' Accept drop of gadgets and windows
  304.       If TypeOf g Is Window Then effect = 1
  305.     End If
  306.   End Sub
  307.  
  308.   Sub EnumMethod(o as object)
  309.     If TypeOf o Is InstallButton.InstallPair && o.obj && o.bitmap Then 
  310.       installObject = o.obj
  311.       installBitmap.SetPicture(o.bitmap.GetPicture)
  312.       If InstallSelObj Then InstalledSomething = True
  313.     End If
  314.   End Sub
  315.  
  316.   Function getInstallName As String
  317.     If installObject Then 
  318.       getInstallName = IIf(HostObject(installObject), installObject.Name, installObject)
  319.     Else 
  320.       getInstallName = ""
  321.     End If
  322.   End Function
  323.  
  324.   Sub Install()
  325.     dim o as Object
  326.     Dim f as New File
  327.     ' This is the MOVEMODULECODE
  328.     Dim m as ObjectModule
  329.     m = ModuleManager.ModuleContaining(installObject)
  330.     f.FileName = m.FileName
  331.     f.FileName = App.Path & f.Name & f.Extension
  332.     If f.Exists && Not InstalledSomething Then 
  333.       If YesNoBox.Message("Duplicate Module", f.FileName & " already exists, are you sure you want to overwrite?") = IDYES Then 
  334.         m.SaveAs(f.FileName, False)
  335.         SourceModule = f.FileName
  336.       End If
  337.     Else 
  338.       m.SaveAs(f.FileName, False)
  339.       SourceModule = f.FileName
  340.     End If
  341.     SendEvent TargetPalette.Install(Me)
  342.   End Sub
  343.  
  344.   Sub InstallSample(o as Object, b as Bitmap)
  345.     dim ng as ControlTools.Gadget
  346.   
  347.     ' Move the object into the module containing the "TargetPalette"
  348.     AttachObjectToModule(o, TargetPalette)
  349.   
  350.     ' Insert a new gadget, at the bottom of the TargetPalette
  351.     ng = EmbedObject(TargetPalette, ControlTools.Gadget, UniqueEmbedName(ControlTools.Palette, "SampleGadget"))
  352.     ng.GadgetObject = o
  353.     ng.bitmap.SetPicture(b.GetPicture)
  354.     TargetPalette.ForceLayout(False)
  355.   
  356.   End Sub
  357.  
  358.   Function InstallSelObj As Boolean
  359.     dim CheckOf as New SuspendDebugExceptionTrapping
  360.     If YesNoBox.Message("Install", "Do you want to install '" & InstallName & "'?") = IDYES Then 
  361.       Dim obj as Object
  362.       obj = installObject
  363.       If TargetPalette = Nothing Then TargetPalette = ControlTools.Palette
  364.       Try
  365.         Dim okContinue as long
  366.         Dim CacheMod as ObjectModule
  367.         CacheMod = ModuleManager.CurrentModule
  368.         okContinue = False
  369.         SendEvent TargetPalette.PreInstall(Me, okContinue)
  370.         If okContinue Then 
  371.           SendEvent Install()
  372.           ModuleManager.CurrentModule = CacheMod
  373.         End If
  374.       Catch InstallFail(reason as string)
  375.         MessageBox.Message("Install Failure", reason)
  376.       End Try
  377.       installObject = obj
  378.       InstallSelObj = True
  379.     End If
  380.   End Function
  381.  
  382.   Sub Reset()
  383.     installObject = Nothing
  384.     installBitmap.LoadType = "FileBased"
  385.     installBitmap.FileName = ""
  386.     installBitmap.LoadType = "MemoryBased"
  387.     Picture = DefaultBitmap
  388.     Refresh
  389.   End Sub
  390.  
  391. End Type
  392.  
  393. Type SuspendDebugExceptionTrapping
  394.   Dim debugger As Object
  395.   Dim TrapInterpretiveExceptions As Boolean
  396.   Dim TrapSystemExceptions As Boolean
  397.  
  398.   ' METHODS for object: SuspendDebugExceptionTrapping
  399.   Sub Construct(o As Object)
  400.     ' This code is constructed so it will work whether or not
  401.     ' the "Debugger" object is present in the system.
  402.     debugger = FindObject("Debugger")
  403.     If debugger Then 
  404.       TrapInterpretiveExceptions = debugger.TrapInterpretiveExceptions
  405.       TrapSystemExceptions = debugger.TrapSystemExceptions
  406.       debugger.TrapInterpretiveExceptions = False
  407.       debugger.TrapSystemExceptions = False
  408.     End If
  409.   End Sub
  410.  
  411.   Sub Destruct()
  412.     If debugger Then 
  413.       debugger.TrapInterpretiveExceptions = TrapInterpretiveExceptions
  414.       debugger.TrapSystemExceptions = TrapSystemExceptions
  415.     End If
  416.   End Sub
  417.  
  418. End Type
  419.  
  420. Type HyperControl From Form
  421.  
  422.   ' METHODS for object: HyperControl
  423.   Sub Resize()
  424.     ' Place holder for resize code, to get initial size behavior.
  425.   End Sub
  426.  
  427. End Type
  428.  
  429. Type ScreenLayoutConfigForm From Form
  430.   Type BtnDone From Button
  431.  
  432.     ' METHODS for object: ScreenLayoutConfigForm.BtnDone
  433.     Sub Click
  434.       Parent.Hide
  435.       Parent.ModalResult IDOK
  436.     End Sub
  437.  
  438.   End Type
  439.   Dim BtnSave As New Button
  440.   Dim CbLayouts As New ComboBox
  441.   Dim LayoutSet As ScreenLayoutSet
  442.   Dim BtnRestore As New Button
  443.   Dim BtnSetDefault As New Button
  444.   Dim LblLegend As New Label
  445.   Dim BtnDelete As New Button
  446.   Dim BtnNewLayout As New Button
  447.  
  448.   ' METHODS for object: ScreenLayoutConfigForm
  449.   Sub AddLayoutToList(o As Object)
  450.     ' Add last name-component of embedded layout to list.
  451.     If o && TypeOf o Is ScreenLayout Then 
  452.       Dim item, sn As String
  453.       sn = o.ShortName
  454.       item = IIf(o = LayoutSet.Default__Layout__, "*" & sn, sn)
  455.       CbLayouts.AddItem item
  456.     End If
  457.   End Sub
  458.  
  459.   Sub BtnDelete_Click()
  460.     Dim layout As ScreenLayout
  461.     layout = SelectedLayout
  462.     If layout Then 
  463.       Dim ynBox As New YesNoBox
  464.       If ynBox.Message("Confirm delete layout", "Delete layout: " & SelectedLayoutName & "?") = IDYES Then 
  465.         DestroyObject(layout)
  466.         SaveLayoutSetModule
  467.         ResetList
  468.       End If
  469.     Else 
  470.       CbLayouts.Text = ""
  471.     End If
  472.   End Sub
  473.  
  474.   Sub BtnNewLayout_Click()
  475.     If CbLayouts.Text <> "" && CbLayouts.ItemIndex(CbLayouts.Text) = -1 Then 
  476.       ' The user has typed and name and hasn't saved it.
  477.       ' Pretend the Save button was clicked
  478.       BtnSave_Click
  479.       If IsIdentifierValid(CbLayouts.Text) Then BtnSetDefault_Click
  480.     Else 
  481.       ' The text in the combobox is an existing layout, or doesn't
  482.       ' exist, bring up a input dialog to name the layout
  483.       Dim id as New InputDialog
  484.       Dim HaveGoodName as Boolean
  485.       Dim LastBadName as string
  486.       HaveGoodName = False
  487.       LastBadName = ""
  488.       While Not HaveGoodName
  489.         If id.Execute("Layout Name", "Enter a name for the new layout", LastBadName) = IDOK Then 
  490.           If Not IsIdentifierValid(id.Text) Then 
  491.             Dim err As New MessageBox
  492.             err.SetIconExclamation
  493.             err.Message("Invalid Identifier", """" & id.Text & """ is not a valid identifier")
  494.             LastBadName = id.Text
  495.           Else 
  496.             ' User typed a valid name
  497.             HaveGoodName = True
  498.           End If
  499.         Else 
  500.           ' User hit cancel from the input dialog
  501.           Exit Sub
  502.         End If
  503.       Wend
  504.       ' User type a valid name and hit OK from the input dialog. Put
  505.       ' the name into the ComboBox, then click the Save then SetDefault
  506.       ' buttons
  507.       CbLayouts.Text = id.Text
  508.       BtnSave_Click
  509.       BtnSetDefault_Click
  510.     End If
  511.   End Sub
  512.  
  513.   Sub BtnRestore_Click()
  514.     RestoreSelectedLayout
  515.     Show : BringToTop
  516.   End Sub
  517.  
  518.   Sub BtnSave_Click()
  519.     If LayoutSet Then 
  520.       Dim layoutName As String
  521.       layoutName = SelectedLayoutName
  522.       If layoutName <> "" Then 
  523.         Hide
  524.         LayoutSet.SaveLayout(layoutName)
  525.         SaveLayoutSetModule
  526.         ResetList : CbLayouts.Text = layoutName
  527.         Show : BringToTop
  528.       End If
  529.     End If
  530.   End Sub
  531.  
  532.   Sub BtnSetDefault_Click()
  533.     If LayoutSet Then 
  534.       If CbLayouts.Text = "" Then  ' Clear default layout
  535.         LayoutSet.Default__Layout__ = Nothing
  536.         SaveLayoutSetModule
  537.         ResetList
  538.       Else 
  539.         Dim layout As ScreenLayout
  540.         layout = SelectedLayout ' Set default to selected layout
  541.         If layout Then 
  542.           LayoutSet.Default__Layout__ = layout
  543.           SaveLayoutSetModule
  544.           ResetList
  545.         End If
  546.       End If
  547.     End If
  548.   End Sub
  549.  
  550.   Sub CbLayouts_DblClick()
  551.     RestoreSelectedLayout
  552.   End Sub
  553.  
  554.   Sub Execute(layoutSet As ScreenLayoutSet)
  555.     If layoutSet Then 
  556.       ' Ensure me and my list are made before resetting the list.
  557.       LayoutSet = layoutSet
  558.       LoadForm
  559.       ResetList
  560.       Show
  561.       BringToTop
  562.     End If
  563.   End Sub
  564.  
  565.   Sub ResetList
  566.     CbLayouts.Clear
  567.     If LayoutSet Then EnumObjectEmbeds(LayoutSet, Me, "AddLayoutToList")
  568.   End Sub
  569.  
  570.   Sub Resize()
  571.     Dim m, mm, hm, l, t, w, h, effWidth As Single
  572.     hm = 45 : m = 90 : mm = 180
  573.     effWidth = IIf(ScaleWidth < 3500, 3500, ScaleWidth)
  574.     w = BtnDone.Width
  575.     h = BtnDone.Height
  576.     l = effWidth - w - m
  577.     BtnDone.Move(l, m, w, h)
  578.     t = h + mm
  579.     BtnSave.Move(l, t, w, h)
  580.     t = t + h + hm
  581.     BtnRestore.Move(l, t, w, h)
  582.     t = t + h + hm
  583.     BtnSetDefault.Move(l, t, w, h)
  584.     t = t + h + hm
  585.     BtnDelete.Move(l, t, w, h)
  586.     t = t + h + hm
  587.     BtnNewLayout.Move(l, t, w, h)
  588.     LblLegend.Top = ScaleHeight - LblLegend.Height - m
  589.     CbLayouts.Move(m, m, l - mm, ScaleHeight - LblLegend.Height - mm)
  590.   End Sub
  591.  
  592.   Sub RestoreSelectedLayout()
  593.     Dim layout As ScreenLayout
  594.   
  595.     If CbLayouts.Text = "" Then 
  596.       ' If no layout is selected, just do what envelop normally does on startup
  597.       EnvelopLayoutSet.AutoRestoreLayout
  598.     Else 
  599.       layout = SelectedLayout
  600.       If layout Then 
  601.         layout.RestoreLayout
  602.       Else 
  603.         CbLayouts.Text = ""
  604.       End If
  605.     End If
  606.   End Sub
  607.  
  608.   Sub SaveLayoutSetModule
  609.     If LayoutSet Then 
  610.       ModuleManager.ModuleContaining(LayoutSet).Save
  611.     End If
  612.   End Sub
  613.  
  614.   Function SelectedLayout() As ScreenLayout
  615.     SelectedLayout = Nothing
  616.     If LayoutSet Then 
  617.       Dim layoutName As String
  618.       layoutName = SelectedLayoutName
  619.       If layoutName <> "" Then SelectedLayout = FindEmbed(LayoutSet, layoutName)
  620.     End If
  621.   End Function
  622.  
  623.   Function SelectedLayoutName As String
  624.     SelectedLayoutName = ""
  625.     If LayoutSet Then 
  626.       Dim layoutName As String
  627.       Dim layout As ScreenLayout
  628.       layoutName = CbLayouts.Text
  629.       If layoutName = "" Then 
  630.         layoutName = LayoutSet.DefaultScreenLayoutName
  631.         CbLayouts.Text = layoutName
  632.       Else 
  633.         If Instr(layoutName, "*") = 1 Then layoutName = Mid(layoutName, 2)
  634.         If Not IsIdentifierValid(layoutName) Then 
  635.           Dim err As New MessageBox
  636.           err.SetIconExclamation
  637.           err.Message("Invalid Identifier", """" & layoutName & """ is not a valid identifier")
  638.           Exit Function
  639.         End If
  640.       End If
  641.       SelectedLayoutName = layoutName
  642.     End If
  643.   End Function
  644.  
  645. End Type
  646.  
  647. Type ControlTools
  648.   Type Gadget From ToolGadget
  649.     Property HintText Get getHintText As String
  650.     Property GadgetObject Get getGadgetObject Set setGadgetObject As String
  651.     Dim gadgetObject_ As String
  652.     Dim SourceModule As String
  653.  
  654.     ' METHODS for object: ControlTools.Gadget
  655.     Sub Click()
  656.       If VerifyExistence Then FormEditor.AddObject = FindObject(GadgetObject)
  657.       ' Register with ControlTools.Palette so we pushed back up after add is done.
  658.       If (TypeOf Parent Is ControlTools.Palette) Then Parent.addingGadget = Me
  659.     End Sub
  660.  
  661.     Sub DblClick()
  662.       ' Auto-embed a copy of our control
  663.       dim newObject, addObject As Window
  664.       dim name As String
  665.       dim suspendTrap As New SuspendDebugExceptionTrapping
  666.       ' Clear "adding" state of FormEditor, but remember object to add
  667.       addObject = FindObject(GadgetObject)
  668.       FormEditor.AddObject = Nothing
  669.     
  670.       name = UniqueEmbedName(FormEditor.CurForm, addObject)
  671.       newObject = EmbedObject(FormEditor.CurForm, addObject, name)
  672.       newObject.Left := 60 : newObject.Top := 60
  673.       newObject.Width := 900 : newObject.Height := 450
  674.       newObject.Caption := name
  675.       FormEditor.SelectControl(newObject, False)
  676.       FormEditor.Raise()
  677.     End Sub
  678.  
  679.     Sub Destruct()
  680.       dim o as Window
  681.     
  682.       ' If we represent an object in the controls module, offer to delete it.
  683.       o = FindObject(GadgetObject)
  684.       If o && (ModuleManager.ModuleContaining(Me) = ModuleManager.ModuleContaining(o)) Then 
  685.         Dim YNB as new YesNoBox
  686.         YNB.message = "Would you like to Destroy '" & GadgetObject & "'?"
  687.         YNB.Execute
  688.         If YNB.result = IDYES Then DestroyObject(o)
  689.       End If
  690.     
  691.     End Sub
  692.  
  693.     Function DetailedEdit() as long
  694.       Dim outcome as long
  695.       ' Display Wizard Modally if present
  696.       Try
  697.         CtrlToolGadgetWizard.ng = Me
  698.         outcome = CtrlToolGadgetWizard.ShowModal
  699.         If outcome = IDCANCEL Then 
  700.           DetailedEdit = False
  701.         Else 
  702.           DetailedEdit = True
  703.         End If
  704.       Catch
  705.       End Try
  706.     End Function
  707.  
  708.     Sub DragStart(o as XferData, x,y as single)
  709.       o.ObjectRef = Me
  710.       o.Drag(1)
  711.     End Sub
  712.  
  713.     Function Enable() As Integer
  714.       ' Enabling of Control icons is based on a Form being edited.
  715.       Enable = FormEditor.Editing && FormEditor.CurForm
  716.     End Function
  717.  
  718.     Function getGadgetObject() As String
  719.       getGadgetObject = gadgetObject_
  720.     End Function
  721.  
  722.     Function getHintText() As String
  723.       ' If the GadgetObject is not set or can be found, that is the
  724.       ' hint, otherwise make hint be "<GadgetObject>*" to indicate
  725.       ' that the object is not available.
  726.       getHintText = IIf(Len(GadgetObject) = 0 || FindObject(GadgetObject), GadgetObject, GadgetObject & "*")
  727.     End Function
  728.  
  729.     Sub setGadgetObject(s As String)
  730.       ' Don't allow names of "dynamic"-objects
  731.       If (Not Instr(s, "@")) Then gadgetObject_ = s
  732.     End Sub
  733.  
  734.     Function VerifyExistence As Long
  735.     
  736.       ' Designer's note:
  737.       ' Would it be worthwile to have VerifyExistence return an
  738.       ' "error value" (say 1 if NoSourceModule, 2 if BadSourceModule...)
  739.       ' Instead of the simple True/False?
  740.     
  741.       If FindObject(GadgetObject) Then 
  742.         ' The control exists
  743.         VerifyExistence = True
  744.       Else 
  745.         ' The control doesn't exist
  746.         ' Check for SourceModule
  747.         If SourceModule <> "" Then 
  748.           ' We know where the control originally came from
  749.           ' Try to load it
  750.           Dim o as Object
  751.           o = ModuleManager.LoadModule(SourceModule, False)
  752.           If o = Nothing Then 
  753.             ' Something failed in the LoadModule
  754.             ' We don't have the control and can't get it
  755.             VerifyExistence = False
  756.           Else 
  757.             ' We loaded the module we expect the control to be in
  758.             If FindObject(GadgetObject) Then 
  759.               ' We found the control
  760.               VerifyExistence = True
  761.             Else 
  762.               ' It's not where we expected
  763.               ' We don't have the control and it's not where we thought
  764.               VerifyExistence = False
  765.               ' Unload the module that we loaded
  766.               o.Unload
  767.             End If
  768.           End If
  769.         Else 
  770.           ' We don't have the control and don't know where to get it
  771.           VerifyExistence = False
  772.         End If
  773.       End If
  774.     End Function
  775.  
  776.   End Type
  777.   Type Palette From ObjectBox
  778.     Dim addingGadget As ControlTools.Gadget
  779.     Dim templateGadget As ButtonGadget
  780.     Type GadArrow From ToolGadget
  781.  
  782.       ' METHODS for object: ControlTools.Palette.GadArrow
  783.       Sub Click()
  784.         FormEditor.AddObject = Nothing
  785.         State = "Up"
  786.       End Sub
  787.  
  788.       Sub DragStart(o as XferData, x,y as single)
  789.         ' Override ToolGadget's
  790.       End Sub
  791.  
  792.       Function Enable() As Integer
  793.         Enable = FormEditor.Editing
  794.         If (Parent.addingGadget && Not FormEditor.AddObject) Then 
  795.           Parent.addingGadget.State = "Up"
  796.           Parent.addingGadget = Nothing
  797.         End If
  798.       End Function
  799.  
  800.     End Type
  801.     Dim GadButton As New ControlTools.Gadget
  802.     Dim GadOptionButton As New ControlTools.Gadget
  803.     Dim GadCheckBox As New ControlTools.Gadget
  804.     Dim GadLabel As New ControlTools.Gadget
  805.     Dim GadTextBox As New ControlTools.Gadget
  806.     Dim GadListBox As New ControlTools.Gadget
  807.     Dim GadComboBox As New ControlTools.Gadget
  808.     Dim GadHScrollBar As New ControlTools.Gadget
  809.     Dim GadScrollBar As New ControlTools.Gadget
  810.     Dim GadFrame As New ControlTools.Gadget
  811.     Dim GadGauge As New ControlTools.Gadget
  812.     Dim GadOle As New ControlTools.Gadget
  813.     Dim GadMarkupLayer As New ControlTools.Gadget
  814.     Dim GadPictureBox As New ControlTools.Gadget
  815.     Dim GadImage As New ControlTools.Gadget
  816.     Dim GadIndentedList As New ControlTools.Gadget
  817.     Dim GadObjectHierarchy As New ControlTools.Gadget
  818.     Dim GadObjectList As New ControlTools.Gadget
  819.     Dim GadObjectCombo As New ControlTools.Gadget
  820.     Dim GadFileListBox As New ControlTools.Gadget
  821.     Dim GadFileComboBox As New ControlTools.Gadget
  822.     Dim GadDataControl As New ControlTools.Gadget
  823.     Dim GadGLControl As New ControlTools.Gadget
  824.     Dim GadRichTextBox As New ControlTools.Gadget
  825.     Dim GadListView As New ControlTools.Gadget
  826.     Dim GadTabStrip As New ControlTools.Gadget
  827.     Dim GadHyperControl As New ControlTools.Gadget
  828.     Dim GadMenu As New ToolGadget
  829.     Dim GadInstallButton As New ControlTools.Gadget
  830.     Dim GadObjectBox As New ControlTools.Gadget
  831.     Dim Empty As New ControlTools.Gadget
  832.  
  833.     Dim lastGad_ As ButtonGadget
  834.     Property DropFeedbackGadget Get getLastGadget Set setLastGadget As Object
  835.  
  836.     Event Install(Package as Object)
  837.     Event PreInstall(Package as Object, ok as long, LastMod as Long)
  838.  
  839.     ' METHODS for object: ControlTools.Palette
  840.     Sub DragAndDrop(o as XferData, x,y as single, state as OleDropState, effect as OleDropEffect)
  841.       Dim nm as String
  842.       Dim dropObj as object
  843.       Dim underPoint As ButtonGadget
  844.       Dim suspend as new SuspendDebugExceptionTrapping
  845.     
  846.       ' Remember the object dropped and the gadget it was dropped on
  847.       dropObj = o.ObjectRef
  848.       underPoint = AtPoint(x, y)
  849.     
  850.       ' Default to "don't accept"
  851.       effect = 0
  852.     
  853.       ' Don't allow a gadget to be dropped on itself. If no object dropped,
  854.       ' forget it, also if no gadget under point forget it also.
  855.       If Not dropObj || Not underPoint || dropObj = underPoint Then Exit Sub
  856.     
  857.       ' If DROP ...
  858.       If state = "Drop" Then 
  859.         ' Disable feedback for drop location
  860.         DropFeedbackGadget = Nothing
  861.     
  862.         ' If gadget from this palette is dropped on another gadget in this
  863.         ' palette...
  864.         If TypeOf dropObj Is ButtonGadget And dropObj.Parent = Me Then 
  865.           ' Swap the positions of control gadgets on same palette
  866.           dropObj.Position = underPoint.Position
  867.     
  868.         ElseIf TypeOf dropObj Is Window Then 
  869.           ' If a "Window" is dropped on the palette, make a gadget at the
  870.           ' drop location, set its "GadgetObject" to the dropped window
  871.           ' and allow the user to edit it.
  872.           Dim ng as ControlTools.Gadget
  873.           Dim name as String
  874.           Dim installObj as Object
  875.     
  876.           name = IIf(HostObject(dropObj), dropObj.Name, dropObj)
  877.     
  878.           Try
  879.             ng = EmbedObject(Me, ControlTools.Gadget, "Gad" & name)
  880.             ng.Position = underPoint.Position + 1
  881.           catch MatchingFieldCollision
  882.             InfoBox.Message("Install Failed", "A control by this name is already installed.")
  883.             Exit Sub
  884.           End Try
  885.  
  886.           ' do a forec layout to ensure that the new addition shows up
  887.           ForceLayout(0)
  888.           ng.GadgetObject = dropObj
  889.           ng.DetailedEdit
  890.     
  891.           ' If the edit comes back successfully, move the object into the palette.
  892.           ' Otherwise, remove the gadget.
  893.           installObj = IIf(ng.GadgetObject <> "", FindObject(ng.GadgetObject), Nothing)
  894.           If Not installObj Then 
  895.             DestroyObject(ng)
  896.           Else 
  897.             Dim f as New File
  898.             ' This is the MOVEMODULECODE
  899.             Dim m as ObjectModule
  900.             m = ModuleManager.ModuleContaining(FindObject(ng.GadgetObject))
  901.             f.FileName = m.FileName
  902.             f.FileName = App.Path & f.Name & f.Extension
  903.             If f.Exists Then 
  904.               If YesNoBox.Message("Duplicate Module", f.FileName & " already exists, are you sure you want to overwrite?") = IDYES Then 
  905.                 m.SaveAs(f.FileName, False)
  906.                 ng.SourceModule = f.FileName
  907.               End If
  908.             Else 
  909.               m.SaveAs(f.FileName, False)
  910.               ng.SourceModule = f.FileName
  911.             End If
  912.           End If
  913.         Else 
  914.           ' Reject the drop
  915.           Exit Sub
  916.         End If
  917.     
  918.         ' Accept the drop
  919.         effect = 1
  920.     
  921.       ElseIf state = 1 Then  ' DRAG LEAVE
  922.         ' Disable feedback for drop location
  923.         DropFeedbackGadget = Nothing
  924.     
  925.       Else  ' DRAG OVER
  926.         ' Accept drop of gadgets and windows
  927.         If Not TypeOf underPoint Is ControlTools.Gadget Then Exit Sub
  928.         If (TypeOf dropObj Is ButtonGadget && dropObj.Parent = Me) || TypeOf dropObj Is Window Then 
  929.           ' Provide feedback for drop location
  930.           effect = 1
  931.           DropFeedbackGadget = underPoint
  932.     
  933.         End If
  934.       End If
  935.     End Sub
  936.  
  937.     Sub GadMenu_Click()
  938.       ' If there is a form under the sway of the form editor,
  939.       ' then embed a menu bar within the form if it isn't there
  940.       ' already
  941.       If FormEditor.Editing && FormEditor.CurForm && FormEditor.CurForm.Visible Then 
  942.         Dim f as Form
  943.         DIm m as Menu
  944.         f = FormEditor.CurForm
  945.         If f.MenuBar = Nothing Then 
  946.           f.MenuBar = EmbedObject(f, MenuBar, UniqueEmbedName(f, "menubar"))
  947.           m = EmbedObject(f.MenuBar, PopupMenu, "Popup1")
  948.           f.MenuBar.InsertPopup(m, "&File", -1)
  949.         End If
  950.         MenuEdit.ProcessMenu f.MenuBar
  951.         MenuEdit.Show
  952.         MenuEdit.BringToTop
  953.       End If
  954.     End Sub
  955.  
  956.     Function GadMenu_Enable() As Integer
  957.       GadMenu_Enable = FormEditor.Editing && FormEditor.CurForm && FormEditor.CurForm.Visible
  958.     End Function
  959.  
  960.     Function getLastGadget() as ButtonGadget
  961.       getLastGadget = lastGad_
  962.     End Function
  963.  
  964.     Sub Install(Package as Object)
  965.       If TypeOf Package Is InstallButton Then 
  966.         dim o as Object
  967.         dim b as Bitmap
  968.         dim ng as ControlTools.Gadget
  969.     
  970.         o = Package.installObject
  971.         b = Package.installBitmap
  972.     
  973.         ' Insert a new gadget, at the bottom of the TargetPalette
  974.         ng = EmbedObject(Me, ControlTools.Gadget, "Gad" & Package.InstallName)
  975.         ng.GadgetObject = o
  976.         ng.bitmap.SetPicture(b.GetPicture)
  977.         ng.SourceModule = Package.SourceModule
  978.         ForceLayout(False)
  979.     
  980.       Else 
  981.         Throw InstallFail("Object sent to Install is not an InstallButton")
  982.       End If
  983.     End Sub
  984.  
  985.     Sub KeyDown(keyCode As Integer, ByVal shift As Integer)
  986.       If (keyCode = VK_F1) Then Envelop.Help.ShowTopicHelp("Controls_Palette")
  987.     End Sub
  988.  
  989.     Sub PreInstall(Package as Object, ok as long)
  990.       If TypeOf Package Is InstallButton Then 
  991.         If FindEmbed(Me, "Gad" & Package.InstallName) Then 
  992.           ok = False
  993.           Throw InstallFail("A ToolGadget already exists for " & Package.InstallName)
  994.         Else 
  995.           ModuleManager.CurrentModule = ModuleManager.ModuleContaining(Me)
  996.           ok = True
  997.         End If
  998.       Else 
  999.         Throw InstallFail("Object sent to PreInstall is not an InstallButton")
  1000.       End If
  1001.     End Sub
  1002.  
  1003.     Sub setLastGadget(g as ButtonGadget)
  1004.       If lastGad_ And g <> lastGad_ Then lastGad_.State = 0
  1005.       lastGad_ = g
  1006.       If lastGad_ Then lastGad_.State = 1
  1007.     End Sub
  1008.  
  1009.   End Type
  1010. End Type
  1011.  
  1012. Type ToolBitmap From Form
  1013.   Dim LblBitmap As New Label
  1014.   Dim TBBitmap As New TextBox
  1015.   Dim BtnFinish As New Button
  1016.   Type ImgGraphic From Image
  1017.     Dim bitmap As New Bitmap
  1018.   End Type
  1019.   Dim LblInstruction As New Label
  1020.   Dim Frame1 As New Frame
  1021.   Type BTNBrowse From Button
  1022.  
  1023.     ' METHODS for object: ToolBitmap.BTNBrowse
  1024.     Sub BtnBrowse_Click()
  1025.       Dim open as New OpenDialog
  1026.     
  1027.       ' Set the title of the open dialog just before we display it.
  1028.       open.Title = "Configure Tool Gadget"
  1029.     
  1030.       ' Set the filter to look for bitmaps
  1031.       open.Filter = "Bitmap files|*.bmp"
  1032.     
  1033.       ' If a filename was picked, then remember it
  1034.       ' Let the picture on this wizard preview it
  1035.       If open.Execute <> IDCANCEL Then 
  1036.         TBBitmap.Text = open.FileName
  1037.       End If
  1038.     End Sub
  1039.  
  1040.   End Type
  1041.   Type SampleBox From ObjectBox
  1042.     Dim PreviewTool As New ToolGadget
  1043.  
  1044.     ' METHODS for object: ToolBitmap.SampleBox
  1045.     Sub Reposition
  1046.       dim l,t,w,h as long
  1047.       w = PreviewTool.bitmap.Width * 15
  1048.       If w > 4125 Then w = 4125
  1049.       If w < 150 Then w = 150
  1050.       h = PreviewTool.bitmap.Height * 15
  1051.       If h > 1575 Then h = 1575
  1052.       If h < 150 Then h = 150
  1053.       l = 2850 + ((4125 - w) / 2)
  1054.       t = 2175 + ((1575 - h) / 2)
  1055.       Move(l, t, w, h)
  1056.       PreviewTool.Refresh
  1057.       ForceLayout(True)
  1058.     End Sub
  1059.  
  1060.   End Type
  1061.   Dim BTNPreview As New Button
  1062.   Dim Caller As InstallButton
  1063.  
  1064.   ' METHODS for object: ToolBitmap
  1065.   Sub BTNBrowse_Click()
  1066.     Dim length As Integer
  1067.     Dim open as New OpenDialog
  1068.   
  1069.     ' Set the title of the open dialog just before we display it.
  1070.     open.Title = "Configure Tool Gadget"
  1071.   
  1072.     ' Set the filter to look for bitmaps
  1073.     open.Filter = "Bitmap files|*.bmp"
  1074.   
  1075.     ' If a filename was picked, then remember it
  1076.     ' Let the picture on this wizard preview it
  1077.     If open.Execute <> IDCANCEL Then 
  1078.       TBBitmap.Text = open.FileName
  1079.       BTNPreview_Click
  1080.     End If
  1081.   End Sub
  1082.  
  1083.   Sub BtnFinish_Click()
  1084.     If Caller = Nothing Then 
  1085.       Throw NoCaller
  1086.     Else 
  1087.       Caller.installBitmap.LoadType = "FileBased"
  1088.       Caller.installBitmap.FileName = TBBitmap.Text
  1089.       Caller.installBitmap.LoadType = "MemoryBased"
  1090.       Caller.Refresh
  1091.       Caller = Nothing
  1092.       Hide
  1093.     End If
  1094.   End Sub
  1095.  
  1096.   Sub BTNPreview_Click()
  1097.     SampleBox.PreviewTool.bitmap.FileName = TBBitmap.Text
  1098.     SampleBox.Reposition
  1099.   End Sub
  1100.  
  1101. End Type
  1102.  
  1103. Type ToolPalette From ObjectBox
  1104.   Property DropFeedbackGadget Get getLastGadget Set setLastGadget As Object
  1105.   Dim lastGad_ As ButtonGadget
  1106.   Type AlignGadget From ToolGadget
  1107.     Dim alignType As Long
  1108.  
  1109.     ' METHODS for object: ToolPalette.AlignGadget
  1110.     Sub Click()
  1111.       FormEditor.Align(alignType)
  1112.     End Sub
  1113.  
  1114.     Function Enable() As Integer
  1115.       Enable = FormEditor.NumSelected > 1
  1116.     End Function
  1117.  
  1118.   End Type
  1119.   Dim AlignR As New ToolPalette.AlignGadget
  1120.   Dim AlignT As New ToolPalette.AlignGadget
  1121.   Dim AlignB As New ToolPalette.AlignGadget
  1122.   Dim AlignLR As New ToolPalette.AlignGadget
  1123.   Dim AlignTB As New ToolPalette.AlignGadget
  1124.   Type SpaceH From ToolGadget
  1125.  
  1126.     ' METHODS for object: ToolPalette.SpaceH
  1127.     Sub Click()
  1128.       FormEditor.AlignHorizontally(5)
  1129.     End Sub
  1130.  
  1131.     Function Enable() As Integer
  1132.       Enable = FormEditor.NumSelected > 1
  1133.     End Function
  1134.  
  1135.   End Type
  1136.   Type SpaceV From ToolGadget
  1137.  
  1138.     ' METHODS for object: ToolPalette.SpaceV
  1139.     Sub Click()
  1140.       FormEditor.AlignVertically(5)
  1141.     End Sub
  1142.  
  1143.     Function Enable() As Integer
  1144.       Enable = FormEditor.NumSelected > 1
  1145.     End Function
  1146.  
  1147.   End Type
  1148.   Type ToggleGrid From ToolGadget
  1149.  
  1150.     ' METHODS for object: ToolPalette.ToggleGrid
  1151.     Sub Click()
  1152.       FormEditor.GridOn = Not FormEditor.GridOn
  1153.     End Sub
  1154.  
  1155.     Function Enable() As Integer
  1156.       Enable = FormEditor.Editing && FormEditor.CurForm
  1157.       If (FormEditor.GridOn) Then State = "Down" Else State = "Up"
  1158.     End Function
  1159.  
  1160.   End Type
  1161.   Type FormEditorUndo From ToolGadget
  1162.     Property HintText Get getHintText As String
  1163.  
  1164.     ' METHODS for object: ToolPalette.FormEditorUndo
  1165.     Sub Click()
  1166.       FormEditor.Undo()
  1167.     End Sub
  1168.  
  1169.     Function Enable() As Integer
  1170.       Enable = ObjectEditorMgr.NextUndoItem <> "None"
  1171.     End Function
  1172.  
  1173.     Function getHintText() As String
  1174.       getHintText = "Undo: " & ObjectEditorMgr.NextUndoItem
  1175.     End Function
  1176.  
  1177.   End Type
  1178.   Type FormEditorRedo From ToolGadget
  1179.     Property HintText Get getHintText As String
  1180.  
  1181.     ' METHODS for object: ToolPalette.FormEditorRedo
  1182.     Sub Click()
  1183.       FormEditor.Redo()
  1184.     End Sub
  1185.  
  1186.     Function Enable() As Integer
  1187.       Enable = ObjectEditorMgr.NextRedoItem <> "None"
  1188.     End Function
  1189.  
  1190.     Function getHintText() As String
  1191.       getHintText = "Redo: " & ObjectEditorMgr.NextRedoItem
  1192.     End Function
  1193.  
  1194.   End Type
  1195.   Type TouchMode From ToolGadget
  1196.  
  1197.     ' METHODS for object: ToolPalette.TouchMode
  1198.     Sub Click()
  1199.       FormEditor.HitMode = "RgnTouches"
  1200.     End Sub
  1201.  
  1202.     Function Enable() As Integer
  1203.       Enable = FormEditor.Editing && FormEditor.CurForm
  1204.       If (FormEditor.HitMode = "RgnTouches") Then 
  1205.         State = "Down"
  1206.       Else 
  1207.         State = "Up"
  1208.       End If
  1209.     End Function
  1210.  
  1211.   End Type
  1212.   Type ContainsMode From ToolGadget
  1213.  
  1214.     ' METHODS for object: ToolPalette.ContainsMode
  1215.     Sub Click()
  1216.       FormEditor.HitMode = "RgnContains"
  1217.     End Sub
  1218.  
  1219.     Function Enable() As Integer
  1220.       Enable = FormEditor.Editing && FormEditor.CurForm
  1221.       If (FormEditor.HitMode = "RgnContains") Then State = "Down" Else State = "Up"
  1222.     End Function
  1223.  
  1224.   End Type
  1225.   Type CopyGadget From ToolGadget
  1226.  
  1227.     ' METHODS for object: ToolPalette.CopyGadget
  1228.     Sub Click()
  1229.       FormEditor.CopyControls()
  1230.     End Sub
  1231.  
  1232.     Function Enable() As Integer
  1233.       Enable = FormEditor.NumSelected > 0
  1234.     End Function
  1235.  
  1236.   End Type
  1237.   Type Arrange From ToolGadget
  1238.  
  1239.     ' METHODS for object: ToolPalette.Arrange
  1240.     Sub Click()
  1241.       If (FormEditor.NumSelected > 0) Then 
  1242.         FedArray.ShowModal()
  1243.       End If
  1244.     End Sub
  1245.  
  1246.     Function Enable() As Integer
  1247.       Enable = FormEditor.NumSelected > 0
  1248.     End Function
  1249.  
  1250.   End Type
  1251.   Type Raise From ToolGadget
  1252.  
  1253.     ' METHODS for object: ToolPalette.Raise
  1254.     Sub Click()
  1255.       FormEditor.Raise()
  1256.     End Sub
  1257.  
  1258.     Function Enable() As Integer
  1259.       Enable = FormEditor.NumSelected > 0
  1260.     End Function
  1261.  
  1262.   End Type
  1263.   Type Lower From ToolGadget
  1264.  
  1265.     ' METHODS for object: ToolPalette.Lower
  1266.     Sub Click()
  1267.       FormEditor.Lower()
  1268.     End Sub
  1269.  
  1270.     Function Enable() As Integer
  1271.       Enable = FormEditor.NumSelected > 0
  1272.     End Function
  1273.  
  1274.   End Type
  1275.   Type ToggleTab From ToolGadget
  1276.  
  1277.     ' METHODS for object: ToolPalette.ToggleTab
  1278.     Sub Click()
  1279.       FormEditor.ShowOrder = Not FormEditor.ShowOrder
  1280.     End Sub
  1281.  
  1282.     Function Enable() As Integer
  1283.       Enable = FormEditor.Editing && FormEditor.CurForm
  1284.     End Function
  1285.  
  1286.   End Type
  1287.   Type FontSet From ToolGadget
  1288.  
  1289.     ' METHODS for object: ToolPalette.FontSet
  1290.     Sub Click()
  1291.       ' Post common font panel to select font
  1292.       If (FontPicker.Execute() = 1) Then 
  1293.         If FormEditor.NumSelected Then 
  1294.           Dim i As Integer
  1295.           For i = 0 To FormEditor.NumSelected - 1
  1296.             FormEditor.GetSelected(i).Font = FontPicker.FontRef
  1297.           Next i
  1298.         Else 
  1299.           FormEditor.CurForm.Font = FontPicker.FontRef
  1300.         End If
  1301.       End If
  1302.     End Sub
  1303.  
  1304.     Function Enable() As Integer
  1305.       Enable = FormEditor.Editing && FormEditor.CurForm
  1306.     End Function
  1307.  
  1308.   End Type
  1309.   Type FColorSet From ToolGadget
  1310.  
  1311.     ' METHODS for object: ToolPalette.FColorSet
  1312.     Sub Click()
  1313.       ' Post common font panel to select font
  1314.       If (ColorDialog.Execute() = 1) Then 
  1315.         If FormEditor.NumSelected Then 
  1316.           Dim i As Integer
  1317.           For i = 0 To FormEditor.NumSelected - 1
  1318.             FormEditor.GetSelected(i).ForeColor = ColorDialog.Color
  1319.           Next i
  1320.         End If
  1321.       End If
  1322.     End Sub
  1323.  
  1324.     Function Enable() As Integer
  1325.       Enable = FormEditor.NumSelected > 0
  1326.     End Function
  1327.  
  1328.   End Type
  1329.   Type BColorSet From ToolGadget
  1330.  
  1331.     ' METHODS for object: ToolPalette.BColorSet
  1332.     Sub Click()
  1333.       ' Post common font panel to select font
  1334.       If (ColorDialog.Execute() = 1) Then 
  1335.         If FormEditor.NumSelected Then 
  1336.           Dim i As Integer
  1337.           For i = 0 To FormEditor.NumSelected - 1
  1338.             FormEditor.GetSelected(i).BackColor = ColorDialog.Color
  1339.           Next i
  1340.         Else 
  1341.           FormEditor.CurForm.BackColor = ColorDialog.Color
  1342.         End If
  1343.       End If
  1344.     End Sub
  1345.  
  1346.     Function Enable() As Integer
  1347.       Enable = FormEditor.Editing && FormEditor.CurForm
  1348.     End Function
  1349.  
  1350.   End Type
  1351.   Type ToggleObjectBoxEdit From ToolGadget
  1352.  
  1353.     ' METHODS for object: ToolPalette.ToggleObjectBoxEdit
  1354.     Sub Click()
  1355.       ObjectBoxEditor.ObjBoxForm.Visible = (State = "Down")
  1356.       If ObjectBoxEditor.ObjBoxForm.Visible Then ObjectBoxEditor.ObjBoxForm.SetCaption
  1357.     End Sub
  1358.  
  1359.   End Type
  1360.  
  1361.   ' METHODS for object: ToolPalette
  1362.   Sub DragAndDrop(o as XferData, x,y as single, state as OleDropState, effect as OleDropEffect)
  1363.     Dim nm as String
  1364.     dim dropObj as object
  1365.     dim underPoint As ButtonGadget
  1366.   
  1367.     dropObj = o.ObjectRef
  1368.     underPoint = AtPoint(x, y)
  1369.   
  1370.     ' Default to "don't accept"
  1371.     effect = 0
  1372.   
  1373.     ' Don't allow a gadget to be dropped on itself. If no object dropped,
  1374.     ' forget it.
  1375.     If Not dropObj || dropObj = underPoint Then Exit Sub
  1376.   
  1377.     ' If DROP ...
  1378.     If state = 3 Then 
  1379.       ' Disable feedback for drop location
  1380.       DropFeedbackGadget = Nothing
  1381.   
  1382.       ' Dropped gadget...
  1383.       If TypeOf dropObj Is ButtonGadget && dropObj.Parent = Me Then 
  1384.         ' Swap the positions of gadgets on same palette
  1385.         dropObj.Position = underPoint.Position
  1386.   
  1387.         ' Accept the drop
  1388.         effect = 1
  1389.       End If
  1390.   
  1391.     ElseIf state = 1 Then  ' DRAG LEAVE
  1392.       ' Disable feedback for drop location
  1393.       DropFeedbackGadget = Nothing
  1394.   
  1395.     Else  ' DRAG OVER
  1396.       ' Accept drop of ButtonGadgets from OUR PALETTE.
  1397.       If TypeOf dropObj Is ButtonGadget && dropObj.Parent = Me Then 
  1398.         effect = 1
  1399.   
  1400.         ' Provide feedback for drop location
  1401.         DropFeedbackGadget = underPoint
  1402.   
  1403.       End If
  1404.     End If
  1405.   End Sub
  1406.  
  1407.   Function getLastGadget() as ButtonGadget
  1408.     getLastGadget = lastGad_
  1409.   End Function
  1410.  
  1411.   Sub KeyDown(keyCode As Integer, ByVal shift As Integer)
  1412.     If (keyCode = VK_F1) Then Envelop.Help.ShowTopicHelp("Tools_Palette")
  1413.   End Sub
  1414.  
  1415.   Sub setLastGadget(g as ButtonGadget)
  1416.     If lastGad_ And g <> lastGad_ Then lastGad_.State = 0
  1417.     lastGad_ = g
  1418.     If lastGad_ Then lastGad_.State = 1
  1419.   End Sub
  1420.  
  1421. End Type
  1422.  
  1423. Type FedArray From Form
  1424.   Dim Label1 As New Label
  1425.   Dim Label2 As New Label
  1426.   Dim Rows As New TextBox
  1427.   Dim Label3 As New Label
  1428.   Dim Columns As New TextBox
  1429.   Dim Label4 As New Label
  1430.   Dim WidthBox As New TextBox
  1431.   Dim Label5 As New Label
  1432.   Dim HeightBox As New TextBox
  1433.   Dim Label6 As New Label
  1434.   Dim ResizeBox As New CheckBox
  1435.   Dim Xoffset As New TextBox
  1436.   Dim Label7 As New Label
  1437.   Dim Yoffset As New TextBox
  1438.   Dim Label8 As New Label
  1439.   Dim OK As New Button
  1440.   Dim Cancel As New Button
  1441.   Dim runMode As Integer
  1442.  
  1443.   ' METHODS for object: FedArray
  1444.   Sub Cancel_Click()
  1445.     ModalResult(-1) : Hide
  1446.   End Sub
  1447.  
  1448.   Sub OK_Click()
  1449.     dim r,c,rs,cs,w,h,rz as integer
  1450.     r = Rows.Text
  1451.     c = Columns.Text
  1452.     cs = Xoffset.Text
  1453.     rs = Yoffset.Text
  1454.     w = WidthBox.Text
  1455.     h = HeightBox.Text
  1456.     rz = ResizeBox.Value
  1457.     ModalResult(0) : Hide
  1458.   
  1459.     If (runMode) Then 
  1460.       FormEditor.ArrangeArray(r, c, rs, cs, w, h, rz)
  1461.     Else 
  1462.       FormEditor.CreateArray(r, c, rs, cs, w, h, rz)
  1463.     End If
  1464.   End Sub
  1465.  
  1466.   Function ShowModal() As Long
  1467.     dim f strictly as Form
  1468.     dim w as Window
  1469.   
  1470.     ' Make sure Form is created, so configurations below stick.
  1471.     LoadForm()
  1472.   
  1473.     If (FormEditor.NumSelected = 1) Then 
  1474.       Caption = "Duplicate control in array pattern"
  1475.       runMode = 0
  1476.     ElseIf (FormEditor.NumSelected > 1) Then 
  1477.       Caption = "Arrange controls as an array"
  1478.       runMode = 1
  1479.     Else 
  1480.       ShowModal = 0
  1481.       Exit Function
  1482.     End If
  1483.   
  1484.     w = FormEditor.GetSelected(0)
  1485.     Columns.Text = 1
  1486.     Rows.Text = FormEditor.NumSelected
  1487.     Xoffset.Text = 1
  1488.     Yoffset.Text = 1
  1489.     WidthBox.Text = w.Width / Screen.TwipsPerPixelX
  1490.     HeightBox.Text = w.Height / Screen.TwipsPerPixelY
  1491.     ResizeBox.Value = 0
  1492.   
  1493.     f = Me
  1494.     ShowModal = f.ShowModal()
  1495.   
  1496.   End Function
  1497.  
  1498. End Type
  1499.  
  1500. Type DataControl From HyperControl
  1501.   Dim DataMoveFirst As New Button
  1502.   Dim DataMovePrev As New Button
  1503.   Dim DataMoveNext As New Button
  1504.   Dim DataMoveLast As New Button
  1505.   Dim DataLabel As New TextBox
  1506.   Dim ButtonScale As Single
  1507.   Dim RecordSet As New RecordSet
  1508.  
  1509.   ' METHODS for object: DataControl
  1510.   Sub DataMoveFirst_Click()
  1511.     RecordSet.MoveFirst
  1512.   End Sub
  1513.  
  1514.   Sub DataMoveLast_Click()
  1515.     RecordSet.MoveLast
  1516.   End Sub
  1517.  
  1518.   Sub DataMoveNext_Click()
  1519.     RecordSet.MoveNext
  1520.     If RecordSet.EOF Then RecordSet.MovePrev
  1521.   End Sub
  1522.  
  1523.   Sub DataMovePrev_Click()
  1524.     RecordSet.MovePrev
  1525.     If RecordSet.BOF Then RecordSet.MoveNext
  1526.   End Sub
  1527.  
  1528.   Function DetailedEdit() As Long
  1529.     DataConConfigureWizard.Edit(Me)
  1530.     DetailedEdit = True
  1531.   End Function
  1532.  
  1533.   Sub Refresh()
  1534.     Dim f Strictly as Form
  1535.     f = Me
  1536.     f.Refresh
  1537.     RecordSet.Refresh
  1538.   End Sub
  1539.  
  1540.   Sub Resize()
  1541.     DataMoveFirst.Move(0, 0, ScaleWidth / ButtonScale, ScaleHeight)
  1542.     DataMovePrev.Move(DataMoveFirst.Width, 0, ScaleWidth / ButtonScale, ScaleHeight)
  1543.     DataLabel.Move(DataMovePrev.Left + DataMovePrev.Width, 0, ScaleWidth * (ButtonScale - 4) / ButtonScale, ScaleHeight)
  1544.     DataMoveNext.Move(DataLabel.Left + DataLabel.Width, 0, ScaleWidth / ButtonScale, ScaleHeight)
  1545.     DataMoveLast.Move(DataMoveNext.Left + DataMoveNext.Width, 0, ScaleWidth / ButtonScale, ScaleHeight)
  1546.   End Sub
  1547.  
  1548. End Type
  1549.  
  1550. Type WindowLayoutItem
  1551.   Dim wnd As Object
  1552.   Dim top As Single
  1553.   Dim width As Single
  1554.   Dim height As Single
  1555.   Dim visible As Boolean
  1556.   Dim left_ As Single
  1557. End Type
  1558.  
  1559. Type HScrollBar From ScrollBar
  1560. End Type
  1561.  
  1562. Type HelpFile From File
  1563.   Dim IsShowing As Integer
  1564.  
  1565.   ' METHODS for object: HelpFile
  1566.   Sub Contents()
  1567.     If Exists Then 
  1568.       WinHelp(App.MainForm.hWnd, FileName, HELP_FORCEFILE, 0)
  1569.       WinHelp(App.MainForm.hWnd, FileName, HELP_CONTENTS, 0)
  1570.       IsShowing = True
  1571.     End If
  1572.   End Sub
  1573.  
  1574.   Sub GotoContext(context As Long)
  1575.     If Exists Then 
  1576.       WinHelp(App.MainForm.hWnd, FileName, HELP_CONTEXT, context)
  1577.       IsShowing = True
  1578.     End If
  1579.   End Sub
  1580.  
  1581.   Sub HelpTopics()
  1582.     If Exists Then 
  1583.       WinHelp(App.MainForm.hWnd, FileName, HELP_FINDER, 0)
  1584.       IsShowing = True
  1585.     End If
  1586.   End Sub
  1587.  
  1588.   Sub Index()
  1589.     If Exists Then 
  1590.       WinHelp(App.MainForm.hWnd, FileName, HELP_INDEX, 0)
  1591.       IsShowing = True
  1592.     End If
  1593.   End Sub
  1594.  
  1595.   Sub Quit()
  1596.     If IsShowing Then 
  1597.       WinHelp(App.MainForm.hWnd, FileName, HELP_QUIT, 0)
  1598.       IsShowing = False
  1599.     End If
  1600.   End Sub
  1601.  
  1602. End Type
  1603.  
  1604. Type FontPicker From Form
  1605.   Dim Cancel As New Button
  1606.   Dim OK As New Button
  1607.   Dim NothingButton As New Button
  1608.   Dim FontRef As Font
  1609.   Dim Workaround As Font
  1610.   Dim Sample As New TextBox
  1611.   Dim ObjList As New ObjectList
  1612.   Dim BtnNewFont As New Button
  1613.   Dim AllowNewFont As Boolean
  1614.  
  1615.   ' METHODS for object: FontPicker
  1616.   Sub BtnNewFont_Click()
  1617.     Dim ID As New InputDialog
  1618.     Dim FName As String
  1619.     Dim GoodName, Cancelled As Boolean
  1620.     Dim MB As New MessageBox
  1621.     GoodName = False
  1622.     Cancelled = False
  1623.     FName = ""
  1624.     While Not GoodName && Not Cancelled
  1625.       If ID.Execute("New Font", "Please Enter a Name for the New Top-Level Font", FName) = IDOK Then 
  1626.         ' User Clicked OK. Verify that Font is legal...
  1627.         FName = ID.Text
  1628.         If Not ValidName(FName) Then 
  1629.           MB.Message("Invalid Name", FName & " is not valid, please try again.")
  1630.         Else 
  1631.           ' Name is a legal identifier, now check to see if it exists
  1632.           If FindObject(FName) Then 
  1633.             MB.Message("Invalid Name", "An object named " & FName & " already exists. Please try again.")
  1634.           Else 
  1635.             ' Name is a legal identifier, and isn't used. We're set!
  1636.             GoodName = True
  1637.           End If
  1638.         End If
  1639.       Else 
  1640.         Cancelled = True
  1641.       End If
  1642.     Wend
  1643.     ' If the user cancelled, this block will be skipped
  1644.     If GoodName Then 
  1645.       Dim FD As New FontDialog
  1646.       ' Need to use FindObject to get the top-level font, and not the
  1647.       ' font reference on the button
  1648.       FD.Font = CopyObject(FindObject("Font"), FName)
  1649.       If Not FD.Font Then 
  1650.         ' FD.Font should ALWAYS be something at this point
  1651.       Else 
  1652.         If FD.Execute = IDOK Then 
  1653.           ' Configuration complete. Reset the ObjList, and select the
  1654.           ' user's new font.
  1655.           ObjList.Reset
  1656.           ObjList.SelObject = FD.Font
  1657.         Else 
  1658.           ' They cancelled the FontDialog, ask if they want to keep the font
  1659.           Dim YNB As New YesNoBox
  1660.           If YNB.Message("Keep Old Font?", "Do you want to keep " & FName) = IDNO Then 
  1661.             ' User doesn't want the font, and it's still in the FontDialog. Whack it!
  1662.             DestroyObject(FD.Font)
  1663.           End If
  1664.         End If
  1665.       End If
  1666.     End If
  1667.   End Sub
  1668.  
  1669.   Sub Cancel_Click()
  1670.     Hide() : ModalResult(0)
  1671.   End Sub
  1672.  
  1673.   Function Execute() As Integer
  1674.     Show()
  1675.     ObjList.SelObject = FontRef
  1676.     ObjList_Click()
  1677.     BtnNewFont.Visible = AllowNewFont
  1678.   
  1679.     Execute = ShowModal()
  1680.   End Function
  1681.  
  1682.   Sub Load()
  1683.     ' Overcome a serious name conflict
  1684.     ObjList.RootObject = Workaround
  1685.   End Sub
  1686.  
  1687.   Sub NothingButton_Click()
  1688.     FontRef = Nothing
  1689.     OK_Click()
  1690.   End Sub
  1691.  
  1692.   Sub ObjList_Click()
  1693.     FontRef = ObjList.SelObject
  1694.     Sample.Font = FontRef
  1695.   End Sub
  1696.  
  1697.   Sub ObjList_DblClick()
  1698.     ' Use font dialog to set it
  1699.     Dim FD As New FontDialog
  1700.     FD.Title = ObjList.SelObject
  1701.     FD.Font = ObjList.SelObject
  1702.     FD.Color = 0
  1703.     FD.Execute
  1704.   End Sub
  1705.  
  1706.   Sub OK_Click()
  1707.     Hide() : ModalResult(1)
  1708.   End Sub
  1709.  
  1710.   Function ValidName(ByVal namestr As String) As Boolean
  1711.     Dim i, char As Integer
  1712.   
  1713.     ' The Empty string is invalid
  1714.     If namestr = "" Then 
  1715.       ValidName = False
  1716.       Exit Sub
  1717.     End If
  1718.   
  1719.     ' Make sure the first Char isn't a number or _
  1720.     char = Asc(Left$(namestr, 1))
  1721.     If (char >= 48 && char <= 57) || (char = 95) Then 
  1722.       ValidName = False
  1723.       Exit Function
  1724.     End If
  1725.   
  1726.     ' Only legal Chars are Letters (Either Case), Numbers and _. Verify
  1727.     ' That EVERY char in the string is one of these cases.
  1728.     For i = 1 To Len(namestr)
  1729.       char = Asc(Mid$(namestr, i, 1))
  1730.       If (char < 65 || char > 90) && (char < 97 || char > 122) Then 
  1731.         If (char < 48 || char > 57) && (char <> 95) Then 
  1732.           ValidName = False
  1733.           Exit Function
  1734.         End If
  1735.       End If
  1736.     Next i
  1737.     ValidName = True
  1738.   End Function
  1739.  
  1740. End Type
  1741.  
  1742. Type ScreenLayoutSet
  1743.   Dim Default__Layout__ As ScreenLayout
  1744.  
  1745.   ' METHODS for object: ScreenLayoutSet
  1746.   Sub AutoRestoreLayout
  1747.     Dim layout As ScreenLayout
  1748.   
  1749.     ' First check our cached default layout
  1750.     layout = Default__Layout__
  1751.     If Not layout || Not layout.FitsScreen Then 
  1752.       ' See if there's a layout named exactly "ScreenWxH"
  1753.       Dim layoutName As String
  1754.       layoutName = DefaultScreenLayoutName
  1755.       layout = FindEmbed(Me, layoutName)
  1756.   
  1757.       If Not layout Then 
  1758.         ' OK, last shot. Pick the biggest layout that fits. Uses the
  1759.         ' Default__Layout__ as a scratch-pad reference.
  1760.         Dim tmpLayout As ScreenLayout
  1761.         tmpLayout = Default__Layout__
  1762.         Default__Layout__ = Nothing
  1763.         EnumObjectEmbeds(Me, Me, "FindBestLayout")
  1764.         layout = Default__Layout__
  1765.         Default__Layout__ = tmpLayout
  1766.       End If
  1767.     End If
  1768.   
  1769.     If layout Then layout.RestoreLayout
  1770.   End Sub
  1771.  
  1772.   Sub Clear
  1773.     ' Destroy all embedded layouts
  1774.     Dim sl As ScreenLayout
  1775.     For Each sl EmbeddedIn Me
  1776.       DestroyObject(o)
  1777.     Next 
  1778.   End Sub
  1779.  
  1780.   Function DefaultScreenLayoutName As String
  1781.     DefaultScreenLayoutName = IIf(Default__Layout__, Default__Layout__.ShortName, "ScreenLayout" & Screen.pixelWidth & "x" & Screen.pixelHeight)
  1782.   End Function
  1783.  
  1784.   Sub FindBestLayout(o As Object)
  1785.     ' Compare layout to the previous best layout. If this layout fits
  1786.     ' on screen and covers more area, then it's better. See "AutoRestoreLayout" method
  1787.     If (TypeOf o Is ScreenLayout) && o.FitsScreen Then 
  1788.       If Not Default__Layout__ Then 
  1789.         Default__Layout__ = o
  1790.       Else 
  1791.         Dim areaPrev, areaThis As Double
  1792.         areaPrev = Default__Layout__.ScreenWidth * Default__Layout__.ScreenHeight
  1793.         areaThis = o.ScreenWidth * o.ScreenHeight
  1794.         If areaThis > areaPrev Then Default__Layout__ = o
  1795.       End If
  1796.     End If
  1797.   End Sub
  1798.  
  1799.   Function SaveLayout(layoutName As String) As ScreenLayout
  1800.     Dim layout As ScreenLayout
  1801.     SaveLayout = Nothing
  1802.   
  1803.     ' Find or create the embedded layout in me.
  1804.     layout = FindEmbed(Me, layoutName)
  1805.     If Not layout Then 
  1806.       layout = EmbedObject(Me, ScreenLayout, layoutName)
  1807.       If Not layout Then Exit Function
  1808.     End If
  1809.   
  1810.     ' Tell the layout to save the current screen.
  1811.     layout.SaveLayout
  1812.     SaveLayout = layout
  1813.   End Function
  1814.  
  1815. End Type
  1816.  
  1817. Type SuspendIgnoreExceptions
  1818.   Dim debugger As Object
  1819.   Dim IgnoreExceptionsModule As Integer
  1820.  
  1821.   ' METHODS for object: SuspendIgnoreExceptions
  1822.   Sub Construct(o As Object)
  1823.     ' This code is constructed so it will work whether or not
  1824.     ' the "Debugger" object is present in the system.
  1825.     debugger = FindObject("Debugger")
  1826.     If debugger Then 
  1827.       IgnoreExceptionsModule = debugger.IgnoreExceptionsModule
  1828.       debugger.IgnoreExceptionsModule = -1
  1829.     End If
  1830.   End Sub
  1831.  
  1832.   Sub Destruct()
  1833.     If debugger Then debugger.IgnoreExceptionsModule = IgnoreExceptionsModule
  1834.   End Sub
  1835.  
  1836. End Type
  1837.  
  1838. Type TempTextFile From TextFile
  1839.   Dim prefix As String
  1840.  
  1841.   ' METHODS for object: TempTextFile
  1842.   Sub Destruct()
  1843.     ' Delete the file.
  1844.     Delete
  1845.   End Sub
  1846.  
  1847.   Function Init() As Boolean
  1848.     ' Generate a unique file name in the TEMP dir.
  1849.     InitializeFileName("")
  1850.   
  1851.     ' OK, we have a unique filename (which might exist).
  1852.     ' Create & open the file empty.
  1853.     Create(True)
  1854.     Init = Exists && IsOpen
  1855.   End Function
  1856.  
  1857.   Sub InitializeFileName(name As String)
  1858.     ' 
  1859.     ' Does nothing if FileName is already set.
  1860.     ' Otherwise, sets FileName up one of two ways:
  1861.     ' - No given name: generates a unique name of form %TEMP%\tmpXXXXX.tmp
  1862.     ' - Given name: sets name to %TEMP%\name
  1863.     ' 
  1864.     If FileName = "" Then 
  1865.       Dim result As Long
  1866.       Dim tmpBuf As New DataBuffer
  1867.       Dim tempPath As String
  1868.       Dim pfx As String
  1869.       tmpBuf.Size = 260
  1870.       pfx = IIf(prefix = "", "tmp", prefix)
  1871.   
  1872.       ' Get TEMP dir.
  1873.       result = GetTempPath(tmpBuf.Size, tmpBuf.Data)
  1874.       If result = 0 || result > tmpBuf.Size Then 
  1875.         Init = False
  1876.         Exit Function
  1877.       End If
  1878.       tempPath = tmpBuf.GetString(0)
  1879.   
  1880.       If name = "" Then 
  1881.         ' Generate temp file name in TEMP dir.
  1882.         result = GetTempFileName(tempPath, pfx, 0, tmpBuf.Data)
  1883.         If result = 0 Then 
  1884.           Init = False
  1885.           Exit Function
  1886.         End If
  1887.         FileName = tmpBuf.GetString(0)
  1888.       Else 
  1889.         FileName = tempPath & name
  1890.       End If
  1891.     End If
  1892.   End Sub
  1893.  
  1894.   Function InitWithName(name As String) As Boolean
  1895.     ' Prepend the TEMP dir to name and set FileName to that.
  1896.     InitializeFileName(name)
  1897.   
  1898.     ' OK, we have a filename in the TEMP dir (which might exist).
  1899.     ' Create & open the file empty. Caller beware! We don't try
  1900.     ' to be nice here: if we can get it, it's gone.
  1901.     If Exists && ReadOnly Then ReadOnly = False
  1902.     Create(True)
  1903.     InitWithName = Exists && IsOpen
  1904.   End Function
  1905.  
  1906. End Type
  1907.  
  1908. Begin Code
  1909. ' Reconstruction commands for object: ScreenLayout
  1910. '
  1911.   With ScreenLayout
  1912.     .curItem := 0
  1913.     .ScreenWidth := 0
  1914.     .ScreenHeight := 0
  1915.   End With  'ScreenLayout
  1916. ' Reconstruction commands for object: ToolGadget
  1917. '
  1918.   With ToolGadget
  1919.     .HintText := ""
  1920.     With .bitmap
  1921.       .LoadType := "MemoryBased"
  1922.     End With  'ToolGadget.bitmap
  1923.   End With  'ToolGadget
  1924. ' Reconstruction commands for object: InstallButton
  1925. '
  1926.   With InstallButton
  1927.     .Move(0, 0, 450, 450)
  1928.     .BevelOuter := "Raised"
  1929.     .Outlined := True
  1930.     .Picture := InstallButton.DefaultBitmap
  1931.     .installObject := Nothing
  1932.     .SourceModule := ""
  1933.     .InstalledSomething := False
  1934.     .TargetPalette := Nothing
  1935.     With .BmpOpen
  1936.       .Title := "Specify bitmap for Sample Icon"
  1937.       .NoChangeDir := False
  1938.     End With  'InstallButton.BmpOpen
  1939.     With .installBitmap
  1940.       .LoadType := "MemoryBased"
  1941.     End With  'InstallButton.installBitmap
  1942.     With .DefaultBitmap
  1943.       .LoadType := "MemoryBased"
  1944.     End With  'InstallButton.DefaultBitmap
  1945.     With .InstallPair
  1946.       .bitmap := Nothing
  1947.       .obj := Nothing
  1948.     End With  'InstallButton.InstallPair
  1949.   End With  'InstallButton
  1950. ' Reconstruction commands for object: SuspendDebugExceptionTrapping
  1951. '
  1952.   With SuspendDebugExceptionTrapping
  1953.     .debugger := Nothing
  1954.     .TrapInterpretiveExceptions := False
  1955.     .TrapSystemExceptions := False
  1956.   End With  'SuspendDebugExceptionTrapping
  1957. ' Reconstruction commands for object: HyperControl
  1958. '
  1959.   With HyperControl
  1960.     .Move(0, 0, 3600, 4320)
  1961.     .Outlined := True
  1962.     .MaxButton := False
  1963.     .MinButton := False
  1964.   End With  'HyperControl
  1965. ' Reconstruction commands for object: ScreenLayoutConfigForm
  1966. '
  1967.   With ScreenLayoutConfigForm
  1968.     .Caption := "Configure Layouts"
  1969.     .Font := DefaultDialogFont
  1970.     .Move(4110, 1905, 3810, 2745)
  1971.     .CancelButton := ScreenLayoutConfigForm.BtnDone
  1972.     .MaxButton := False
  1973.     .LayoutSet := Nothing
  1974.     With .BtnDone
  1975.       .Caption := "Done"
  1976.       .ZOrder := 7
  1977.       .Move(2505, 90, 1095, 315)
  1978.     End With  'ScreenLayoutConfigForm.BtnDone
  1979.     With .BtnSave
  1980.       .Caption := "&Save"
  1981.       .ZOrder := 6
  1982.       .Move(2505, 495, 1095, 315)
  1983.     End With  'ScreenLayoutConfigForm.BtnSave
  1984.     With .CbLayouts
  1985.       .ZOrder := 5
  1986.       .Move(90, 90, 2325, 1905)
  1987.       .Style := "SimpleCombo"
  1988.     End With  'ScreenLayoutConfigForm.CbLayouts
  1989.     With .BtnRestore
  1990.       .Caption := "&Restore"
  1991.       .ZOrder := 4
  1992.       .Move(2505, 855, 1095, 315)
  1993.     End With  'ScreenLayoutConfigForm.BtnRestore
  1994.     With .BtnSetDefault
  1995.       .Caption := "Set de&fault"
  1996.       .ZOrder := 3
  1997.       .Move(2505, 1215, 1095, 315)
  1998.     End With  'ScreenLayoutConfigForm.BtnSetDefault
  1999.     With .LblLegend
  2000.       .Caption := "* = default screen layout"
  2001.       .ZOrder := 2
  2002.       .Move(240, 1995, 2130, 195)
  2003.     End With  'ScreenLayoutConfigForm.LblLegend
  2004.     With .BtnDelete
  2005.       .Caption := "&Delete"
  2006.       .ZOrder := 1
  2007.       .Move(2505, 1575, 1095, 315)
  2008.     End With  'ScreenLayoutConfigForm.BtnDelete
  2009.     With .BtnNewLayout
  2010.       .Caption := "&New"
  2011.       .ZOrder := 1
  2012.       .Move(2505, 1965, 1095, 315)
  2013.     End With  'ScreenLayoutConfigForm.BtnNewLayout
  2014.   End With  'ScreenLayoutConfigForm
  2015. ' Reconstruction commands for object: ControlTools
  2016. '
  2017.   With ControlTools
  2018.     With .Gadget
  2019.       .ButtonType := "Exclusive"
  2020.       .GadgetObject := ""
  2021.       .gadgetObject_ := ""
  2022.       .SourceModule := ""
  2023.       With .bitmap
  2024.       End With  'ControlTools.Gadget.bitmap
  2025.     End With  'ControlTools.Gadget
  2026.     With .Palette
  2027.       .Caption := "Controls"
  2028.       .ZOrder := 1
  2029.       .Move(14370, 1125, 915, 6945)
  2030.       .addingGadget := Nothing
  2031.       .templateGadget := ControlTools.Gadget
  2032.       .lastGad_ := Nothing
  2033.       .DropFeedbackGadget := Nothing
  2034.       With .GadArrow
  2035.         .Position := 1
  2036.         .HintText := "Cancel Add Control"
  2037.         With .bitmap
  2038.           .FileName := "tools.ero"
  2039.           .ResId := 0
  2040.         End With  'ControlTools.Palette.GadArrow.bitmap
  2041.       End With  'ControlTools.Palette.GadArrow
  2042.       With .GadButton
  2043.         .Position := 2
  2044.         .GadgetObject := "Button"
  2045.         .gadgetObject_ := "Button"
  2046.         With .bitmap
  2047.           .FileName := "tools.ero"
  2048.           .ResId := 404
  2049.         End With  'ControlTools.Palette.GadButton.bitmap
  2050.       End With  'ControlTools.Palette.GadButton
  2051.       With .GadOptionButton
  2052.         .Position := 3
  2053.         .GadgetObject := "OptionButton"
  2054.         .gadgetObject_ := "OptionButton"
  2055.         With .bitmap
  2056.           .FileName := "tools.ero"
  2057.           .ResId := 808
  2058.         End With  'ControlTools.Palette.GadOptionButton.bitmap
  2059.       End With  'ControlTools.Palette.GadOptionButton
  2060.       With .GadCheckBox
  2061.         .Position := 4
  2062.         .GadgetObject := "CheckBox"
  2063.         .gadgetObject_ := "CheckBox"
  2064.         With .bitmap
  2065.           .FileName := "tools.ero"
  2066.           .ResId := 1212
  2067.         End With  'ControlTools.Palette.GadCheckBox.bitmap
  2068.       End With  'ControlTools.Palette.GadCheckBox
  2069.       With .GadLabel
  2070.         .Position := 5
  2071.         .GadgetObject := "Label"
  2072.         .gadgetObject_ := "Label"
  2073.         With .bitmap
  2074.           .FileName := "tools.ero"
  2075.           .ResId := 1616
  2076.         End With  'ControlTools.Palette.GadLabel.bitmap
  2077.       End With  'ControlTools.Palette.GadLabel
  2078.       With .GadTextBox
  2079.         .Position := 6
  2080.         .GadgetObject := "TextBox"
  2081.         .gadgetObject_ := "TextBox"
  2082.         With .bitmap
  2083.           .FileName := "tools.ero"
  2084.           .ResId := 2020
  2085.         End With  'ControlTools.Palette.GadTextBox.bitmap
  2086.       End With  'ControlTools.Palette.GadTextBox
  2087.       With .GadListBox
  2088.         .Position := 7
  2089.         .GadgetObject := "ListBox"
  2090.         .gadgetObject_ := "ListBox"
  2091.         With .bitmap
  2092.           .FileName := "tools.ero"
  2093.           .ResId := 2424
  2094.         End With  'ControlTools.Palette.GadListBox.bitmap
  2095.       End With  'ControlTools.Palette.GadListBox
  2096.       With .GadComboBox
  2097.         .Position := 8
  2098.         .GadgetObject := "ComboBox"
  2099.         .gadgetObject_ := "ComboBox"
  2100.         With .bitmap
  2101.           .FileName := "tools.ero"
  2102.           .ResId := 2828
  2103.         End With  'ControlTools.Palette.GadComboBox.bitmap
  2104.       End With  'ControlTools.Palette.GadComboBox
  2105.       With .GadHScrollBar
  2106.         .Position := 9
  2107.         .GadgetObject := "HScrollBar"
  2108.         .gadgetObject_ := "HScrollBar"
  2109.         With .bitmap
  2110.           .FileName := "tools.ero"
  2111.           .ResId := 3232
  2112.         End With  'ControlTools.Palette.GadHScrollBar.bitmap
  2113.       End With  'ControlTools.Palette.GadHScrollBar
  2114.       With .GadScrollBar
  2115.         .Position := 10
  2116.         .GadgetObject := "ScrollBar"
  2117.         .gadgetObject_ := "ScrollBar"
  2118.         With .bitmap
  2119.           .FileName := "tools.ero"
  2120.           .ResId := 3636
  2121.         End With  'ControlTools.Palette.GadScrollBar.bitmap
  2122.       End With  'ControlTools.Palette.GadScrollBar
  2123.       With .GadFrame
  2124.         .Position := 11
  2125.         .GadgetObject := "Frame"
  2126.         .gadgetObject_ := "Frame"
  2127.         With .bitmap
  2128.           .FileName := "tools.ero"
  2129.           .ResId := 4040
  2130.         End With  'ControlTools.Palette.GadFrame.bitmap
  2131.       End With  'ControlTools.Palette.GadFrame
  2132.       With .GadGauge
  2133.         .Position := 12
  2134.         .GadgetObject := "Gauge"
  2135.         .gadgetObject_ := "Gauge"
  2136.         With .bitmap
  2137.           .FileName := "tools.ero"
  2138.           .ResId := 4444
  2139.         End With  'ControlTools.Palette.GadGauge.bitmap
  2140.       End With  'ControlTools.Palette.GadGauge
  2141.       With .GadOle
  2142.         .Position := 13
  2143.         .GadgetObject := "Ole"
  2144.         .gadgetObject_ := "Ole"
  2145.         With .bitmap
  2146.           .FileName := "tools.ero"
  2147.           .ResId := 4848
  2148.         End With  'ControlTools.Palette.GadOle.bitmap
  2149.       End With  'ControlTools.Palette.GadOle
  2150.       With .GadMarkupLayer
  2151.         .Position := 14
  2152.         .GadgetObject := "MarkupLayer"
  2153.         .gadgetObject_ := "MarkupLayer"
  2154.         With .bitmap
  2155.           .FileName := "tools.ero"
  2156.           .ResId := 5252
  2157.         End With  'ControlTools.Palette.GadMarkupLayer.bitmap
  2158.       End With  'ControlTools.Palette.GadMarkupLayer
  2159.       With .GadPictureBox
  2160.         .Position := 15
  2161.         .GadgetObject := "PictureBox"
  2162.         .gadgetObject_ := "PictureBox"
  2163.         With .bitmap
  2164.           .FileName := "tools.ero"
  2165.           .ResId := 5656
  2166.         End With  'ControlTools.Palette.GadPictureBox.bitmap
  2167.       End With  'ControlTools.Palette.GadPictureBox
  2168.       With .GadImage
  2169.         .Position := 16
  2170.         .GadgetObject := "Image"
  2171.         .gadgetObject_ := "Image"
  2172.         With .bitmap
  2173.           .FileName := "tools.ero"
  2174.           .ResId := 6060
  2175.         End With  'ControlTools.Palette.GadImage.bitmap
  2176.       End With  'ControlTools.Palette.GadImage
  2177.       With .GadIndentedList
  2178.         .Position := 17
  2179.         .GadgetObject := "IndentedList"
  2180.         .gadgetObject_ := "IndentedList"
  2181.         With .bitmap
  2182.           .FileName := "tools.ero"
  2183.           .ResId := 6464
  2184.         End With  'ControlTools.Palette.GadIndentedList.bitmap
  2185.       End With  'ControlTools.Palette.GadIndentedList
  2186.       With .GadObjectHierarchy
  2187.         .Position := 18
  2188.         .GadgetObject := "ObjectHierarchy"
  2189.         .gadgetObject_ := "ObjectHierarchy"
  2190.         With .bitmap
  2191.           .FileName := "tools.ero"
  2192.           .ResId := 6868
  2193.         End With  'ControlTools.Palette.GadObjectHierarchy.bitmap
  2194.       End With  'ControlTools.Palette.GadObjectHierarchy
  2195.       With .GadObjectList
  2196.         .Position := 19
  2197.         .GadgetObject := "ObjectList"
  2198.         .gadgetObject_ := "ObjectList"
  2199.         With .bitmap
  2200.           .FileName := "tools.ero"
  2201.           .ResId := 7272
  2202.         End With  'ControlTools.Palette.GadObjectList.bitmap
  2203.       End With  'ControlTools.Palette.GadObjectList
  2204.       With .GadObjectCombo
  2205.         .Position := 20
  2206.         .GadgetObject := "ObjectCombo"
  2207.         .gadgetObject_ := "ObjectCombo"
  2208.         With .bitmap
  2209.           .FileName := "tools.ero"
  2210.           .ResId := 7676
  2211.         End With  'ControlTools.Palette.GadObjectCombo.bitmap
  2212.       End With  'ControlTools.Palette.GadObjectCombo
  2213.       With .GadFileListBox
  2214.         .Position := 21
  2215.         .GadgetObject := "FileListBox"
  2216.         .gadgetObject_ := "FileListBox"
  2217.         With .bitmap
  2218.           .FileName := "tools.ero"
  2219.           .ResId := 8080
  2220.         End With  'ControlTools.Palette.GadFileListBox.bitmap
  2221.       End With  'ControlTools.Palette.GadFileListBox
  2222.       With .GadFileComboBox
  2223.         .Position := 22
  2224.         .GadgetObject := "FileComboBox"
  2225.         .gadgetObject_ := "FileComboBox"
  2226.         With .bitmap
  2227.           .FileName := "tools.ero"
  2228.           .ResId := 8484
  2229.         End With  'ControlTools.Palette.GadFileComboBox.bitmap
  2230.       End With  'ControlTools.Palette.GadFileComboBox
  2231.       With .GadGLControl
  2232.         .Position := 23
  2233.         .GadgetObject := "GLControl"
  2234.         .gadgetObject_ := "GLControl"
  2235.         With .bitmap
  2236.           .FileName := "tools.ero"
  2237.           .ResId := 8888
  2238.         End With  'ControlTools.Palette.GadGLControl.bitmap
  2239.       End With  'ControlTools.Palette.GadGLControl
  2240.       With .GadDataControl
  2241.         .Position := 24
  2242.         .GadgetObject := "DataControl"
  2243.         .gadgetObject_ := "DataControl"
  2244.         With .bitmap
  2245.           .FileName := "tools.ero"
  2246.           .ResId := 9292
  2247.         End With  'ControlTools.Palette.GadDataControl.bitmap
  2248.       End With  'ControlTools.Palette.GadDataControl
  2249.       With .GadRichTextBox
  2250.         .Position := 25
  2251.         .GadgetObject := "RichTextBox"
  2252.         .gadgetObject_ := "RichTextBox"
  2253.         With .bitmap
  2254.           .FileName := "tools.ero"
  2255.           .ResId := 14704
  2256.         End With  'ControlTools.Palette.GadRichTextBox.bitmap
  2257.       End With  'ControlTools.Palette.GadRichTextBox
  2258.       With .GadListView
  2259.         .Position := 26
  2260.         .GadgetObject := "ListView"
  2261.         .gadgetObject_ := "ListView"
  2262.         With .bitmap
  2263.           .FileName := "tools.ero"
  2264.           .ResId := 13920
  2265.         End With  'ControlTools.Palette.GadListView.bitmap
  2266.       End With  'ControlTools.Palette.GadListView
  2267.       With .GadTabStrip
  2268.         .Position := 27
  2269.         .GadgetObject := "TabStrip"
  2270.         .gadgetObject_ := "TabStrip"
  2271.         With .bitmap
  2272.           .FileName := "tools.ero"
  2273.           .ResId := 14312
  2274.         End With  'ControlTools.Palette.GadTabStrip.bitmap
  2275.       End With  'ControlTools.Palette.GadTabStrip
  2276.       With .GadHyperControl
  2277.         .Position := 28
  2278.         .GadgetObject := "HyperControl"
  2279.         .gadgetObject_ := "HyperControl"
  2280.         With .bitmap
  2281.           .FileName := "tools.ero"
  2282.           .ResId := 10100
  2283.         End With  'ControlTools.Palette.GadHyperControl.bitmap
  2284.       End With  'ControlTools.Palette.GadHyperControl
  2285.       With .GadMenu
  2286.         .Position := 29
  2287.         .HintText := "Embed Menubar"
  2288.         With .bitmap
  2289.           .FileName := "tools.ero"
  2290.           .ResId := 9696
  2291.         End With  'ControlTools.Palette.GadMenu.bitmap
  2292.       End With  'ControlTools.Palette.GadMenu
  2293.       With .GadInstallButton
  2294.         .Position := 30
  2295.         .GadgetObject := "InstallButton"
  2296.         .gadgetObject_ := "InstallButton"
  2297.         With .bitmap
  2298.           .FileName := "tools.ero"
  2299.           .ResId := 10504
  2300.         End With  'ControlTools.Palette.GadInstallButton.bitmap
  2301.       End With  'ControlTools.Palette.GadInstallButton
  2302.       With .GadObjectBox
  2303.         .Position := 31
  2304.         .GadgetObject := "ObjectBox"
  2305.         .gadgetObject_ := "ObjectBox"
  2306.         With .bitmap
  2307.           .FileName := "tools.ero"
  2308.           .ResId := 12212
  2309.         End With  'ControlTools.Palette.GadObjectBox.bitmap
  2310.       End With  'ControlTools.Palette.GadObjectBox
  2311.       With .Empty
  2312.         .Position := 32
  2313.         With .bitmap
  2314.         End With  'ControlTools.Palette.Empty.bitmap
  2315.       End With  'ControlTools.Palette.Empty
  2316.     End With  'ControlTools.Palette
  2317.   End With  'ControlTools
  2318. ' Reconstruction commands for object: ToolBitmap
  2319. '
  2320.   With ToolBitmap
  2321.     .Caption := "Configure Tool Gadget"
  2322.     .Move(1905, 5850, 7245, 4815)
  2323.     .DefaultButton := ToolBitmap.BtnFinish
  2324.     .BorderStyle := "Fixed Single"
  2325.     .Caller := Nothing
  2326.     With .LblBitmap
  2327.       .Caption := "Picture file:"
  2328.       .ZOrder := 5
  2329.       .Move(2850, 825, 1500, 225)
  2330.     End With  'ToolBitmap.LblBitmap
  2331.     With .TBBitmap
  2332.       .ZOrder := 4
  2333.       .Move(2850, 1125, 4050, 450)
  2334.     End With  'ToolBitmap.TBBitmap
  2335.     With .BtnFinish
  2336.       .Caption := "Done..."
  2337.       .ZOrder := 6
  2338.       .Move(6225, 4050, 825, 300)
  2339.     End With  'ToolBitmap.BtnFinish
  2340.     With .ImgGraphic
  2341.       .ZOrder := 7
  2342.       .Move(225, 225, 2475, 3150)
  2343.       .AutoInitCropRect := False
  2344.       .Picture := ToolBitmap.ImgGraphic.bitmap
  2345.       .ScrollBars := "Never"
  2346.       .CropXSize := 165
  2347.       .CropYSize := 210
  2348.       With .bitmap
  2349.         .LoadType := "MemoryBased"
  2350.       End With  'ToolBitmap.ImgGraphic.bitmap
  2351.     End With  'ToolBitmap.ImgGraphic
  2352.     With .LblInstruction
  2353.       .Caption := "Type a FileName for the bitmap or the ToolGadget, or press Browse..."
  2354.       .ZOrder := 8
  2355.       .Move(2850, 300, 4125, 450)
  2356.     End With  'ToolBitmap.LblInstruction
  2357.     With .Frame1
  2358.       .ZOrder := 9
  2359.       .Move(75, 3825, 6975, 75)
  2360.     End With  'ToolBitmap.Frame1
  2361.     With .BTNBrowse
  2362.       .Caption := "Browse..."
  2363.       .ZOrder := 3
  2364.       .Move(2850, 1725, 1050, 375)
  2365.     End With  'ToolBitmap.BTNBrowse
  2366.     With .SampleBox
  2367.       .Caption := "SampleBox"
  2368.       .ZOrder := 2
  2369.       .Move(4740, 2790, 345, 345)
  2370.       .Visible := True
  2371.       With .PreviewTool
  2372.         .Position := 1
  2373.         .HintText := "I am a frog"
  2374.         With .bitmap
  2375.           .LoadType := "FileBased"
  2376.           .FileName := "W:\test\objbox\objbox.bmp"
  2377.         End With  'ToolBitmap.SampleBox.PreviewTool.bitmap
  2378.       End With  'ToolBitmap.SampleBox.PreviewTool
  2379.     End With  'ToolBitmap.SampleBox
  2380.     With .BTNPreview
  2381.       .Caption := "Preview"
  2382.       .ZOrder := 1
  2383.       .Move(5625, 1725, 1200, 375)
  2384.     End With  'ToolBitmap.BTNPreview
  2385.   End With  'ToolBitmap
  2386. ' Reconstruction commands for object: ToolPalette
  2387. '
  2388.   With ToolPalette
  2389.     .Caption := "Tools"
  2390.     .ZOrder := 1
  2391.     .Move(5025, 1125, 9315, 645)
  2392.     .NumColumns := -1
  2393.     .NumRows := 1
  2394.     .DropFeedbackGadget := Nothing
  2395.     .lastGad_ := Nothing
  2396.     With .AlignGadget
  2397.       .Enabled := False
  2398.       .Position := 1
  2399.       .HintText := "Align Left Edges"
  2400.       .alignType := 1
  2401.       With .bitmap
  2402.         .FileName := "tools.ero"
  2403.         .ResId := 15096
  2404.       End With  'ToolPalette.AlignGadget.bitmap
  2405.     End With  'ToolPalette.AlignGadget
  2406.     With .AlignR
  2407.       .Position := 2
  2408.       .HintText := "Align Right Edges"
  2409.       .alignType := 2
  2410.       With .bitmap
  2411.         .ResId := 15500
  2412.       End With  'ToolPalette.AlignR.bitmap
  2413.     End With  'ToolPalette.AlignR
  2414.     With .AlignT
  2415.       .Position := 3
  2416.       .HintText := "Align Top Edges"
  2417.       .alignType := 4
  2418.       With .bitmap
  2419.         .ResId := 15904
  2420.       End With  'ToolPalette.AlignT.bitmap
  2421.     End With  'ToolPalette.AlignT
  2422.     With .AlignB
  2423.       .Position := 4
  2424.       .HintText := "Align Bottom Edges"
  2425.       .alignType := 8
  2426.       With .bitmap
  2427.         .ResId := 16308
  2428.       End With  'ToolPalette.AlignB.bitmap
  2429.     End With  'ToolPalette.AlignB
  2430.     With .AlignLR
  2431.       .Position := 5
  2432.       .HintText := "Align Left&Right Edges"
  2433.       .alignType := 19
  2434.       With .bitmap
  2435.         .ResId := 16712
  2436.       End With  'ToolPalette.AlignLR.bitmap
  2437.     End With  'ToolPalette.AlignLR
  2438.     With .AlignTB
  2439.       .Position := 6
  2440.       .HintText := "Align Top&Bottom Edges"
  2441.       .alignType := 28
  2442.       With .bitmap
  2443.         .ResId := 17116
  2444.       End With  'ToolPalette.AlignTB.bitmap
  2445.     End With  'ToolPalette.AlignTB
  2446.     With .SpaceH
  2447.       .Enabled := False
  2448.       .Position := 7
  2449.       .HintText := "Proportional Horizontal Spacing"
  2450.       With .bitmap
  2451.         .FileName := "tools.ero"
  2452.         .ResId := 17520
  2453.       End With  'ToolPalette.SpaceH.bitmap
  2454.     End With  'ToolPalette.SpaceH
  2455.     With .SpaceV
  2456.       .Enabled := False
  2457.       .Position := 8
  2458.       .HintText := "Proportional Vertical Spacing"
  2459.       With .bitmap
  2460.         .FileName := "tools.ero"
  2461.         .ResId := 17924
  2462.       End With  'ToolPalette.SpaceV.bitmap
  2463.     End With  'ToolPalette.SpaceV
  2464.     With .ToggleGrid
  2465.       .Position := 9
  2466.       .State := "Down"
  2467.       .ButtonType := "NonExclusive"
  2468.       .HintText := "Toggle Grid"
  2469.       With .bitmap
  2470.         .FileName := "tools.ero"
  2471.         .ResId := 18328
  2472.       End With  'ToolPalette.ToggleGrid.bitmap
  2473.     End With  'ToolPalette.ToggleGrid
  2474.     With .FormEditorUndo
  2475.       .Enabled := False
  2476.       .Position := 10
  2477.       With .bitmap
  2478.         .FileName := "tools.ero"
  2479.         .ResId := 18732
  2480.       End With  'ToolPalette.FormEditorUndo.bitmap
  2481.     End With  'ToolPalette.FormEditorUndo
  2482.     With .FormEditorRedo
  2483.       .Enabled := False
  2484.       .Position := 11
  2485.       With .bitmap
  2486.         .FileName := "tools.ero"
  2487.         .ResId := 19136
  2488.       End With  'ToolPalette.FormEditorRedo.bitmap
  2489.     End With  'ToolPalette.FormEditorRedo
  2490.     With .TouchMode
  2491.       .Position := 12
  2492.       .State := "Down"
  2493.       .ButtonType := "Exclusive"
  2494.       .HintText := "Selection mode: Region Touches"
  2495.       With .bitmap
  2496.         .FileName := "tools.ero"
  2497.         .ResId := 19540
  2498.       End With  'ToolPalette.TouchMode.bitmap
  2499.     End With  'ToolPalette.TouchMode
  2500.     With .ContainsMode
  2501.       .Position := 13
  2502.       .ButtonType := "Exclusive"
  2503.       .HintText := "Selection mode: Region Contains"
  2504.       With .bitmap
  2505.         .FileName := "tools.ero"
  2506.         .ResId := 19944
  2507.       End With  'ToolPalette.ContainsMode.bitmap
  2508.     End With  'ToolPalette.ContainsMode
  2509.     With .CopyGadget
  2510.       .Enabled := False
  2511.       .Position := 14
  2512.       .HintText := "Copy Controls"
  2513.       With .bitmap
  2514.         .FileName := "tools.ero"
  2515.         .ResId := 20348
  2516.       End With  'ToolPalette.CopyGadget.bitmap
  2517.     End With  'ToolPalette.CopyGadget
  2518.     With .Arrange
  2519.       .Enabled := False
  2520.       .Position := 15
  2521.       .HintText := "Arrange Controls"
  2522.       With .bitmap
  2523.         .FileName := "tools.ero"
  2524.         .ResId := 20752
  2525.       End With  'ToolPalette.Arrange.bitmap
  2526.     End With  'ToolPalette.Arrange
  2527.     With .Raise
  2528.       .Enabled := False
  2529.       .Position := 16
  2530.       .HintText := "Raise Controls"
  2531.       With .bitmap
  2532.         .FileName := "tools.ero"
  2533.         .ResId := 21156
  2534.       End With  'ToolPalette.Raise.bitmap
  2535.     End With  'ToolPalette.Raise
  2536.     With .Lower
  2537.       .Enabled := False
  2538.       .Position := 17
  2539.       .HintText := "Lower Controls"
  2540.       With .bitmap
  2541.         .FileName := "tools.ero"
  2542.         .ResId := 21560
  2543.       End With  'ToolPalette.Lower.bitmap
  2544.     End With  'ToolPalette.Lower
  2545.     With .ToggleTab
  2546.       .Position := 18
  2547.       .HintText := "Toggle Tab Order Display"
  2548.       With .bitmap
  2549.         .FileName := "tools.ero"
  2550.         .ResId := 21964
  2551.       End With  'ToolPalette.ToggleTab.bitmap
  2552.     End With  'ToolPalette.ToggleTab
  2553.     With .FontSet
  2554.       .Position := 19
  2555.       .HintText := "Set Font on Selected Controls"
  2556.       With .bitmap
  2557.         .FileName := "tools.ero"
  2558.         .ResId := 22368
  2559.       End With  'ToolPalette.FontSet.bitmap
  2560.     End With  'ToolPalette.FontSet
  2561.     With .FColorSet
  2562.       .Enabled := False
  2563.       .Position := 20
  2564.       .HintText := "Set ForeColor on Selected Controls"
  2565.       With .bitmap
  2566.         .FileName := "tools.ero"
  2567.         .ResId := 22772
  2568.       End With  'ToolPalette.FColorSet.bitmap
  2569.     End With  'ToolPalette.FColorSet
  2570.     With .BColorSet
  2571.       .Position := 21
  2572.       .HintText := "Set BackColor on Selected Controls"
  2573.       With .bitmap
  2574.         .FileName := "tools.ero"
  2575.         .ResId := 23176
  2576.       End With  'ToolPalette.BColorSet.bitmap
  2577.     End With  'ToolPalette.BColorSet
  2578.     With .ToggleObjectBoxEdit
  2579.       .Position := 22
  2580.       .State := "Down"
  2581.       .ButtonType := "NonExclusive"
  2582.       .HintText := "Toggle ObjectBox Editing On/Off"
  2583.       With .bitmap
  2584.         .FileName := "tools.ero"
  2585.         .ResId := 23580
  2586.       End With  'ToolPalette.ToggleObjectBoxEdit.bitmap
  2587.     End With  'ToolPalette.ToggleObjectBoxEdit
  2588.   End With  'ToolPalette
  2589. ' Reconstruction commands for object: FedArray
  2590. '
  2591.   With FedArray
  2592.     .Caption := "Duplicate control in array pattern"
  2593.     .Move(4215, 3180, 5235, 3975)
  2594.     .Outlined := True
  2595.     .DefaultButton := FedArray.OK
  2596.     .CancelButton := FedArray.Cancel
  2597.     .runMode := 0
  2598.     With .Label1
  2599.       .Caption := "Cell layout"
  2600.       .ZOrder := 8
  2601.       .Move(150, 150, 1515, 375)
  2602.     End With  'FedArray.Label1
  2603.     With .Label2
  2604.       .Caption := "Cell size"
  2605.       .ZOrder := 9
  2606.       .Move(2550, 150, 1515, 375)
  2607.     End With  'FedArray.Label2
  2608.     With .Rows
  2609.       .ZOrder := 2
  2610.       .Move(1050, 1125, 1050, 360)
  2611.     End With  'FedArray.Rows
  2612.     With .Label3
  2613.       .Caption := "Columns"
  2614.       .ZOrder := 10
  2615.       .Move(150, 675, 840, 360)
  2616.     End With  'FedArray.Label3
  2617.     With .Columns
  2618.       .ZOrder := 1
  2619.       .Move(1050, 675, 1050, 375)
  2620.     End With  'FedArray.Columns
  2621.     With .Label4
  2622.       .Caption := "Rows"
  2623.       .ZOrder := 11
  2624.       .Move(150, 1125, 900, 375)
  2625.     End With  'FedArray.Label4
  2626.     With .WidthBox
  2627.       .ZOrder := 3
  2628.       .Move(3525, 675, 1110, 360)
  2629.     End With  'FedArray.WidthBox
  2630.     With .Label5
  2631.       .Caption := "Width"
  2632.       .ZOrder := 12
  2633.       .Move(2550, 675, 750, 360)
  2634.     End With  'FedArray.Label5
  2635.     With .HeightBox
  2636.       .ZOrder := 4
  2637.       .Move(3525, 1125, 1110, 360)
  2638.     End With  'FedArray.HeightBox
  2639.     With .Label6
  2640.       .Caption := "Height"
  2641.       .ZOrder := 13
  2642.       .Move(2550, 1125, 900, 360)
  2643.     End With  'FedArray.Label6
  2644.     With .ResizeBox
  2645.       .Caption := "Size controls to cell"
  2646.       .ZOrder := 5
  2647.       .Move(2550, 1650, 2400, 450)
  2648.     End With  'FedArray.ResizeBox
  2649.     With .Xoffset
  2650.       .ZOrder := 6
  2651.       .Move(1050, 1725, 1050, 360)
  2652.     End With  'FedArray.Xoffset
  2653.     With .Label7
  2654.       .Caption := "X offset"
  2655.       .ZOrder := 14
  2656.       .Move(150, 1725, 750, 360)
  2657.     End With  'FedArray.Label7
  2658.     With .Yoffset
  2659.       .ZOrder := 7
  2660.       .Move(1050, 2175, 1050, 360)
  2661.     End With  'FedArray.Yoffset
  2662.     With .Label8
  2663.       .Caption := "Y offset"
  2664.       .ZOrder := 15
  2665.       .Move(150, 2175, 900, 360)
  2666.     End With  'FedArray.Label8
  2667.     With .OK
  2668.       .Caption := "OK"
  2669.       .ZOrder := 16
  2670.       .Move(450, 3000, 1650, 450)
  2671.     End With  'FedArray.OK
  2672.     With .Cancel
  2673.       .Caption := "Cancel"
  2674.       .ZOrder := 17
  2675.       .Move(3000, 3000, 1650, 450)
  2676.     End With  'FedArray.Cancel
  2677.   End With  'FedArray
  2678. ' Reconstruction commands for object: DataControl
  2679. '
  2680.   With DataControl
  2681.     .Move(7515, 5970, 2595, 765)
  2682.     .ButtonScale := 8
  2683.     With .DataMoveFirst
  2684.       .Caption := "<<"
  2685.       .ZOrder := 2
  2686.       .Move(0, 0, 309, 360)
  2687.     End With  'DataControl.DataMoveFirst
  2688.     With .DataMovePrev
  2689.       .Caption := "<"
  2690.       .ZOrder := 3
  2691.       .Move(309, 0, 309, 360)
  2692.     End With  'DataControl.DataMovePrev
  2693.     With .DataMoveNext
  2694.       .Caption := ">"
  2695.       .ZOrder := 4
  2696.       .Move(1855, 0, 309, 360)
  2697.     End With  'DataControl.DataMoveNext
  2698.     With .DataMoveLast
  2699.       .Caption := ">>"
  2700.       .ZOrder := 5
  2701.       .Move(2164, 0, 309, 360)
  2702.     End With  'DataControl.DataMoveLast
  2703.     With .DataLabel
  2704.       .BackColor := 12632256
  2705.       .DragMode := "No Drag"
  2706.       .ZOrder := 6
  2707.       .Move(618, 0, 1237, 360)
  2708.     End With  'DataControl.DataLabel
  2709.   End With  'DataControl
  2710. ' Reconstruction commands for object: WindowLayoutItem
  2711. '
  2712.   With WindowLayoutItem
  2713.     .wnd := Nothing
  2714.     .top := 0
  2715.     .width := 0
  2716.     .height := 0
  2717.     .visible := False
  2718.     .left_ := 0
  2719.   End With  'WindowLayoutItem
  2720. ' Reconstruction commands for object: HScrollBar
  2721. '
  2722.   With HScrollBar
  2723.     .Move(0, 0, 0, 0)
  2724.     .Orientation := "Horizontal"
  2725.     .Move(0, 0, 0, 0)
  2726.   End With  'HScrollBar
  2727. ' Reconstruction commands for object: HelpFile
  2728. '
  2729.   With HelpFile
  2730.     .IsShowing := 0
  2731.   End With  'HelpFile
  2732. ' Reconstruction commands for object: FontPicker
  2733. '
  2734.   With FontPicker
  2735.     .Caption := "Select Font"
  2736.     .Move(7530, 6855, 3135, 4110)
  2737.     .Outlined := True
  2738.     .FontRef := Nothing
  2739.     .Workaround := Font
  2740.     .AllowNewFont := True
  2741.     With .Cancel
  2742.       .Caption := "Cancel"
  2743.       .ForeColor := 4227327
  2744.       .ZOrder := 2
  2745.       .Move(2115, 3225, 750, 375)
  2746.     End With  'FontPicker.Cancel
  2747.     With .BtnNewFont
  2748.       .Caption := "New"
  2749.       .ZOrder := 1
  2750.       .Move(1050, 3225, 900, 375)
  2751.     End With  'FontPicker.BtnNewFont
  2752.     With .OK
  2753.       .Caption := "OK"
  2754.       .ForeColor := 4227327
  2755.       .ZOrder := 3
  2756.       .Move(150, 3225, 750, 375)
  2757.     End With  'FontPicker.OK
  2758.     With .NothingButton
  2759.       .Caption := "Set to ""Nothing"""
  2760.       .ZOrder := 4
  2761.       .Move(75, 2700, 2850, 300)
  2762.     End With  'FontPicker.NothingButton
  2763.     With .Sample
  2764.       .Caption := "AaBbYyZz"
  2765.       .ZOrder := 5
  2766.       .Move(75, 75, 2850, 825)
  2767.     End With  'FontPicker.Sample
  2768.     With .ObjList
  2769.       .Caption := "ObjList"
  2770.       .ZOrder := 6
  2771.       .Move(75, 975, 2850, 1650)
  2772.       .ShowEmbeds := True
  2773.       .RootObject := Font
  2774.     End With  'FontPicker.ObjList
  2775.   End With  'FontPicker
  2776. ' Reconstruction commands for object: ScreenLayoutSet
  2777. '
  2778.   With ScreenLayoutSet
  2779.     .Default__Layout__ := Nothing
  2780.   End With  'ScreenLayoutSet
  2781. ' Reconstruction commands for object: SuspendIgnoreExceptions
  2782. '
  2783.   With SuspendIgnoreExceptions
  2784.     .debugger := Nothing
  2785.     .IgnoreExceptionsModule := 0
  2786.   End With  'SuspendIgnoreExceptions
  2787. ' Reconstruction commands for object: TempTextFile
  2788. '
  2789.   With TempTextFile
  2790.     .prefix := ""
  2791.   End With  'TempTextFile
  2792. End Code
  2793.